Skip to content

Tag: multi-index

Pandas multiIndex slicing by aggregate

I have a pandas Series (S) that has an index like: I have a conditional function that returns a lower dimensional index. What I am doing is performing something like S.groupby(level=(0,1)).median() > 1 This returns a Series with Index like so: How do I slice the original Series with the lower dimensional i…

Select colums in pandas multi index dataframe

I probably have a rather simple pandas question, but despite having tried multiple solutions posted on stackoverflow, I can’t figure out how to do it properly. I have pandas multi-index Dataframe with the following structure: Image1 now I want to select a subset of this dataframe based on the first colu…

setting columns in multiindex pandas

I have this pandas df which i imported from a csv: Is it possible for everything on the left to be grouped under fresh and everything on the right of the dates to be under column spoil in multiindex format. Such as, there is one column which contains [apple, banana, orange]. I want to do this because later wh…