Pandas: get multiindex level as series
I have a dataframe with multiple levels, eg: idx = pd.MultiIndex.from_product((['foo', 'bar'], ['one', 'five', 'three' 'four']), names=['first', 'second']) df = pd.DataFrame({'A': [np.nan, 12, np.nan, 11, 16, 12, 11, np.nan]}, index=idx).dropna().astype(int) A first second foo five 12 four 11 bar one 16 five 12 three 11 I want to create a new column using the index level titled second , so that I get A B first second foo five 12 five four 11 four bar one 16 one five 12 five three 11 three I can do this by resetting the index, copying the column, then re-applying, but that seems more round