Skip to content

Commit

Permalink
correctly accessing the filtered dataframe for selection of tabulator… (
Browse files Browse the repository at this point in the history
#2676)

* correctly accessing the filtered dataframe for selection of tabulator #2642

* removing unused fixture
  • Loading branch information
Stubatiger authored and philippjfr committed Sep 1, 2021
1 parent 261c0cd commit 4d2fe35
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions panel/tests/widgets/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,24 @@ def test_none_table(document, comm):
assert model.source.data == {}


def test_tabulator_selected_dataframe():
df = makeMixedDataFrame()
table = Tabulator(df, selection=[0, 2])

pd.testing.assert_frame_equal(table.selected_dataframe, df.iloc[[0, 2]])


def test_tabulator_selected_and_filtered_dataframe(document, comm):
df = makeMixedDataFrame()
table = Tabulator(df)

pd.testing.assert_frame_equal(table.selected_dataframe, df)

table.add_filter('foo3', 'C')

pd.testing.assert_frame_equal(table.selected_dataframe, df[df["C"] == "foo3"])


def test_tabulator_config_defaults(document, comm):
df = makeMixedDataFrame()
table = Tabulator(df)
Expand Down
4 changes: 2 additions & 2 deletions panel/widgets/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,8 @@ def selected_dataframe(self):
Returns a DataFrame of the currently selected rows.
"""
if not self.selection:
return self.value
return self.value.iloc[self.selection]
return self._processed
return self._processed.iloc[self.selection]



Expand Down

0 comments on commit 4d2fe35

Please sign in to comment.