You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import numpy as np
import pandas as pd
hor= [str(k) for k in range(3)]
columns=[ 'A','B','C', 'D' ]
ind1=np.repeat(hor, len(columns))
ind2=np.tile(columns,4)
df=pd.DataFrame(index=[ind1,ind2],columns=columns)
print(df)
print(df.xs('A',level=1))
generates an error when trying to trying to slice the dataframe. The slicing syntax is correct, but the issue appears because the dataframe is invalid:
len(ind1)= 12 and len(ind2)=16.
I think an error should be generated upon creation of the dataframe.