You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a dataset with date,industry,wage and price. I want to compute the percentage increase in wages and prices by industry. I can do something like:
But this will return me a pandas dataframe with date as an index and wage and price as columns, losing the industry column.
Feature Description
It would be nice to add an option to pct_change(), when applied to a groupby object, to also return the groups, maybe as an index as the agg function does.
Alternative Solutions
My current approach is: pd.concat([data.set_index('date')[['industry']], data.set_index('date').groupby(['industry'])[['wage','price']].pct_change()],axis=1)
Not a big deal but seems a common operation. Having a grouped dataframe and wanting to compute percentage changes for several columns.
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Feature Type
Adding new functionality to pandas
Changing existing functionality in pandas
Removing existing functionality in pandas
Problem Description
I have a dataset with
date,
industry,
wage
andprice.
I want to compute the percentage increase in wages and prices by industry. I can do something like:data.set_index('date').groupby('industry')[['wage','price']].pct_change()
But this will return me a pandas
dataframe
withdate
as an index andwage
andprice
as columns, losing theindustry
column.Feature Description
It would be nice to add an option to pct_change(), when applied to a groupby object, to also return the groups, maybe as an index as the
agg
function does.Alternative Solutions
My current approach is:
pd.concat([data.set_index('date')[['industry']], data.set_index('date').groupby(['industry'])[['wage','price']].pct_change()],axis=1)
Not a big deal but seems a common operation. Having a grouped dataframe and wanting to compute percentage changes for several columns.
Additional Context
No response
The text was updated successfully, but these errors were encountered: