Skip to content
Advertisement

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 index? I know I can reset index and

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 column headers (HDx_DATE) The columns which I want to show

Accessing and overwriting Multiindex df data

I’m trying to multiply all the values of the following multiindex df for which the first multiindex equals Property_2 with a scalar: I’ve tried various ways: but I am getting back nan’s in the relevant places. Answer That’s because the indices don’t match. One way to get around the issue is to assign the underlying numpy array: or you could

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 when i

How do I filter multi-level columns using notnull() in pandas?

I generate a multi-index dataframe that has some NAN values using this: Which will create something like this: I’d like to get rows of a specific subset of top-level columns (eg df[[‘baz’,’qux’]]) that have no nulls. For example in df[[‘baz’,’qux’]] I’d like to get rows 0 and 1 since they both have all nulls in 3. Hoping things would just

Advertisement