4. MultiIndex Flashcards
1
Q
setting up multi index
A
df.set_index([“Date”,”Country”])
df = pd.read_csv(“bigmac.csv”,parse_dates=[“Date”], index_col=[“Date”,”Country”])
2
Q
df.index
A
return tuple
3
Q
breakdown df.index
A
df.index.get_level_values(“Country”)-> return normal index vector
or
df.index.get_level_values(1)
4
Q
change index name
A
df.index.set_names([“Day”,”Location”], inplace=True)
df. index.set_names(“Date”, level = “Day”)
df. index.set_names(“Date”, level = 0)