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

Tabulator: incorrect data aggregation #7449

Open
thuydotm opened this issue Oct 29, 2024 · 0 comments
Open

Tabulator: incorrect data aggregation #7449

thuydotm opened this issue Oct 29, 2024 · 0 comments
Assignees
Labels
component: tabulator Related to the Tabulator widget

Comments

@thuydotm
Copy link
Collaborator

thuydotm commented Oct 29, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: tabulator Related to the Tabulator widget
Projects
None yet
Development

No branches or pull requests

2 participants