Skip to content

Commit

Permalink
Ensure Tabulator supports grouping on numeric columns (#2987)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Dec 7, 2021
1 parent 0869066 commit 0cabeea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 17 additions & 0 deletions panel/tests/widgets/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,23 @@ def test_tabulator_groups(document, comm):
]


def test_tabulator_numeric_groups(document, comm):
df = pd.DataFrame(np.random.rand(10, 3))
table = Tabulator(df, groups={'Number': [0, 1]})

model = table.get_root(document, comm)

assert model.configuration['columns'] == [
{'field': 'index'},
{'title': 'Number',
'columns': [
{'field': '0'},
{'field': '1'}
]},
{'field': '2'}
]


def test_tabulator_frozen_cols(document, comm):
df = makeMixedDataFrame()
table = Tabulator(df, frozen_columns=['index'])
Expand Down
6 changes: 5 additions & 1 deletion panel/widgets/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1343,9 +1343,13 @@ def _config_columns(self, column_objs):
column_objs.remove(cols[0])
ordered += column_objs

grouping = {
group: [str(gc) for gc in group_cols]
for group, group_cols in self.groups.items()
}
for i, column in enumerate(ordered):
matching_groups = [
group for group, group_cols in self.groups.items()
group for group, group_cols in grouping.items()
if column.field in group_cols
]
col_dict = {'field': column.field}
Expand Down

0 comments on commit 0cabeea

Please sign in to comment.