chris1610 / sidetable

sidetable builds simple but useful summary tables of your data
https://pbpython.com
MIT License
385 stars 29 forks source link

Pandas 2.1.1 Subtotal Dropping Index Names #27

Open keg5038 opened 1 year ago

keg5038 commented 1 year ago

Hello! Love the project, @chris1610! I have upgraded Pandas to 2.1.1 & Sidetable is now behaving differently in a couple of areas.

Before the upgrade to 2.1.1, I could call x.stb.subtotal & it would keep the index names. Now, it looks like it is dropping the index names from my multi-level index. Any suggestions?

chris1610 commented 1 year ago

I've finally started to take a look at this and can not reproduce. Can you recreate with the seaborn titanic data:

df = sns.load_dataset('titanic')
df.groupby(['sex', 'class']).agg({'fare': ['sum']}).stb.subtotal()

When I execute the above, I get a deprecation warning but don't think that's the issue you're seeing.

keg5038 commented 1 year ago

Thanks, @chris1610! I just installed an updated conda environment which defaults to pandas '2.0.3'.

In running your code above, it drops the index names ('sex','class') when you add in the stb.subtotal. I've included pics of both here.

Subtotal No subtotal

chris1610 commented 1 year ago

Ah. Got it. I'll look into that.. Thanks for the example.