I have a DataFrame with a MultiIndex fopr the columns.
ipdb> actions
flow inflow outflow
action Investment Trade ExternalFee Fee
date sequence
2016-10-18 50 15000.0 NaN NaN NaN
55 NaN NaN -513.0 NaN
60 NaN -14402.4 NaN NaN
70 NaN NaN NaN -14.29
I wish to reindex thereby adding and 'Income' column.
ipdb> actions.reindex(columns=['Investment', 'Trade', 'ExternalFee', 'Fee', 'Income'], level=1)
flow inflow outflow
action Investment Trade ExternalFee Fee
date sequence
2016-10-18 50 15000.0 NaN NaN NaN
55 NaN NaN -513.0 NaN
60 NaN -14402.4 NaN NaN
70 NaN NaN NaN -14.29
No 'Income' column is added.
I also tried naming the level:
ipdb> actions.reindex(columns=['Investment', 'Trade', 'Income'], level='action')
flow inflow outflow
action Investment Trade
date sequence
2016-10-18 50 15000.0 NaN
55 NaN NaN
60 NaN -14402.4