我有一个如下所示的对话框:
该对话框具有连接到过滤器按钮的以下代码:
class Dialog(QtGui.QDialog, addWin.Ui_Dialog):
...
self.list = QListView()
self.filter.clicked.connect(self.filterClicked)
...
def filterClicked(self):
filter_text = str(self.lineEdit.text()).lower()
for row in range(self.model.rowCount()):
if filter_text in str(self.model.item(row).text()).lower():
self.list.setRowHidden(row, True)
else:
self.list.setRowHidden(row, False)
Run Code Online (Sandbox Code Playgroud)
但是,当我单击“过滤器”时,没有任何反应。我缺少什么?
如果我像这样制作多索引列数据框:
iterables = [['bar', 'baz', 'foo', 'qux'], ['one', 'two']]
index = pd.MultiIndex.from_product(iterables, names=['first', 'second'])
df = pd.DataFrame(np.random.randn(3, 8), index=['A', 'B', 'C'], columns=index)
first bar baz foo qux \
second one two one two one two one
A -0.119687 -0.518318 0.113920 -1.028505 1.106375 -1.020139 -0.039300
B 0.123480 -2.091120 0.464597 -0.147211 -0.489895 -1.090659 -0.592679
C -1.174376 0.282011 -0.197658 -0.030751 0.117374 1.591109 0.796908
first
second two
A -0.938209
B -0.851483
C 0.442621
Run Code Online (Sandbox Code Playgroud)
我想使用列表仅从第一组列中选择列,
select_cols=['bar', 'qux']
这样结果将是:
first bar qux
second one two one …Run Code Online (Sandbox Code Playgroud)