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.

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

from_tuples

[('bar', 'one'), ('bar', 'two'), ('baz', 'one'), ('baz', 'two'), ('foo', 'one'), ('foo', 'two'), ('qux', 'one'), ('qux', 'two')]
MultiIndex(levels=[['bar', 'baz', 'foo', 'qux'], ['one', 'two']], labels=[[0, 0, 1, 1, 2, 2, 3, 3], [0, 1, 0, 1, 0, 1, 0, 1]], names=['first', 'second'])
first second bar one 0.290858 two -1.169035 baz one -1.004513 two -1.017247 foo one 0.034182 two -0.486026 qux one -0.749825 two 0.643422 dtype: float64

Multi-Index

Create a MultiIndex Using set_index

Loading...

DataFrame.set_index can be used to create a regular index.

Loading...

DataFrame.set_index can also be used to create a MultiIndex.

Loading...

Notice that in addition to column names, you can also provide a (non-string) iterable collection.

Loading...