'Pandas GroupBy Reset Index not Resetting
I am trying to reset the index on my dataframe, but the reset_index is not fully resetting the column headers. How would I adjust this to reach my desired outcome?
f = {'Price_x': ['count','mean','median', 'std', q1, q3]}
dfa = df.groupby(['Item','Criteria']).agg(f).reset_index()
print(list(dfa))
Current result:
[('MLS#_y', ''), ('Criteria', ''), ('Price_x', 'count'), ('Price_x', 'mean'), ('Price_x', 'median'), ('Price_x', 'std'), ('Price_x', 'q1'), ('Price_x', 'q3')]
Desired Result:
['Item','Criteria','count','mean','median', ... ]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
