Skip to content

Tabulator: incorrect data aggregation #7449

Open
@thuydotm

Description

ALL software version info

Software Version Info
panel 1.5.3

Description of expected behavior and the observed behavior

Observed behavior: Flat aggregators on Tabulator always give sums for all columns. Nested aggregators always return the first element in the group. Indexes displayed as NaNs. Data grouping works properly though.

Expected behaviors:

  • aggregating correctly based on the specified aggregation methods
  • indexes displayed appropriately.

Complete, minimal, self-contained example code that reproduces the issue

import pandas as pd
import panel as pn

df = pd.DataFrame([
    ('Germany', 2020, 9, 2.4, 'A'),
    ('Germany', 2021, 3, 7.3, 'C'),
    ('Germany', 2022, 6, 3.1, 'B'),
    ('UK', 2020, 5, 8.0, 'A'),
    ('UK', 2021, 1, 3.9, 'B'),
    ('UK', 2022, 9, 2.2, 'A')
], columns=['Country', 'Year', 'Int', 'Float', 'Str']).set_index(['Country', 'Year'])

nested_aggregators = {'Year': {'Int': 'sum', 'Float': 'mean'}}
flat_aggregators = {'Int': 'sum', 'Float': 'mean'}

flat_aggs_tabulator = pn.widgets.Tabulator(
    value=df, hierarchical=True, aggregators=flat_aggregators
)
nested_aggs_tabulator = pn.widgets.Tabulator(
    value=df, hierarchical=True, aggregators=nested_aggregators
)

pn.Accordion(
    ("Flat Aggs", flat_aggs_tabulator),
    ("Nested Aggs", nested_aggs_tabulator)
).servable()

Screenshots or screencasts of the bug in action

image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

component: tabulatorRelated to the Tabulator widgettype: bugSomething isn't correct or isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions