In [8]:
import numpy as np
import pandas as pd
from numpy.random import randn
In [9]:
from beakerx import beakerx, TableDisplay
beakerx.pandas_display_default()
In [11]:
df = pd.DataFrame(
{"month": [1, 4, 7, 10], "year": [2012, 2014, 2013, 2014], "sale": [55, 40, 84, 31]}
)
df
Out[11]:
Add a Level to Row Index¶
In [18]:
df2 = pd.concat([df], keys=["Foo"], names=["Firstlevel"])
df2
Out[18]:
In [19]:
df2.index
Out[19]:
In [20]:
df2.columns
Out[20]:
Add a Level to Column Index¶
In [15]:
df3 = pd.concat([df], keys=["Foo"], names=["Firstlevel"], axis=1)
df3
Out[15]:
In [16]:
df3.columns
Out[16]:
In [17]:
df3.index
Out[17]: