Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Add level to a MultiIndexes in pandas

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Loading...

Add a Level to Row Index

Loading...
MultiIndex(levels=[['Foo'], [0, 1, 2, 3]], labels=[[0, 0, 0, 0], [0, 1, 2, 3]], names=['Firstlevel', None])
Index(['month', 'year', 'sale'], dtype='object')

Add a Level to Column Index

Loading...
MultiIndex(levels=[['Foo'], ['month', 'year', 'sale']], labels=[[0, 0, 0], [0, 1, 2]], names=['Firstlevel', None])
RangeIndex(start=0, stop=4, step=1)