-  
-   Notifications  You must be signed in to change notification settings 
- Fork 19.2k
Closed
Labels
API DesignError ReportingIncorrect or improved errors from pandasIncorrect or improved errors from pandasIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves
Milestone
Description
The following code
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.
Metadata
Metadata
Assignees
Labels
API DesignError ReportingIncorrect or improved errors from pandasIncorrect or improved errors from pandasIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselves