Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correctly accessing the filtered dataframe for selection of tabulator… #2676

Merged
merged 2 commits into from
Aug 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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