0

I cannot find in the documentation a way to show the qgrid table associated with my dataframe pre-filtered

Imagine I have a dataframe like:

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"] })

and initially when displaying the table I only want to show the rows with column "F" equal to fooor bar instead of all (but still have the possibility to choose the others in the qgrid header)

AleAve81
  • 275
  • 3
  • 8

1 Answers1

1

After read some test file on qgrid github. The code below might help. However, the visible row looks different comparing to clicking filter.

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"
    })
Ke Zhang
  • 937
  • 1
  • 10
  • 24