Python 在Qgrid中,是否有一种方法可以在显示表时应用默认行筛选器
我在文档中找不到一种显示与我的数据帧预筛选关联的qgrid表的方法 假设我有一个数据帧,如:Python 在Qgrid中,是否有一种方法可以在显示表时应用默认行筛选器,python,jupyter-notebook,qgrid,Python,Jupyter Notebook,Qgrid,我在文档中找不到一种显示与我的数据帧预筛选关联的qgrid表的方法 假设我有一个数据帧,如: df_types = pd.DataFrame({ 'A' : 1., 'B' : pd.Series(['2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04', '2013-01-05', '2013-01-06', '2013-01-07', '2013-01-08', '2013-01-09'],index=list(ra
df_types = pd.DataFrame({
'A' : 1.,
'B' : pd.Series(['2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04',
'2013-01-05', '2013-01-06', '2013-01-07', '2013-01-08', '2013-01-09'],index=list(range(9)),dtype='datetime64[ns]'),
'C' : pd.Series(randn(9),index=list(range(9)),dtype='float32'),
'D' : np.array([3] * 9,dtype='int32'),
'E' : pd.Categorical(["washington", "adams", "washington", "madison", "lincoln","jefferson", "hamilton", "roosevelt", "kennedy"]),
'F' : ["foo", "bar", "buzz", "bippity","boppity", "foo", "foo", "bar", "zoo"] })
最初显示表格时,我只想显示列“F”等于
foo
或bar
的行,而不是全部(但仍然可以在qgrid标题中选择其他行),然后在qgrid github上读取一些测试文件。下面的代码可能会有所帮助。但是,与单击过滤器相比,可见行看起来有所不同
qw = qgrid.show_grid(df_types, show_toolbar=True)
qw._handle_qgrid_msg_helper({
'type': 'show_filter_dropdown',
'field': 'F',
'search_val': 'bar'
})
qw._handle_qgrid_msg_helper({
'field': "F",
'filter_info': {
'field': "F",
'selected': [0],
'type': "text",
'excluded': []
},
'type': "change_filter"
})