New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Unexpected IndexingError when filtering with .loc #46551
Comments
@bikoboshi
to add another example for noncommutativity
|
@mctessi If it was just dimensions, that would be tolerable. However, the exception I'm seeing is also dependent on value. The below code runs fine. Whether it should? I'm not sure; I'm just looking for consistency. >>> a = pd.Series([True, False])
>>> b = pd.Series([False, False]).astype('boolean')
>>> s = pd.Series([1,2])
>>> s.loc[a].loc[b]
Series([], dtype: int64) |
@bikoboshi
Anyway, I agree that it is inconsistent behavior and totally surprised me! |
take |
@bikoboshi |
@mctessi |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
The example throws an unexpected indexing error. The error seems to trigger if the first filter is neither the identity nor empty and when combined with the second filter with nan is empty. The error does not seem to trigger otherwise.
Expected Behavior
I expect this identity to hold
s.loc[a].loc[b] == s.loc[b].loc[a] == s.loc[a & b]
which it does except for the exception above.Installed Versions
pandas : 1.3.5
numpy : 1.17.4
pytz : 2019.1
dateutil : 2.8.0
pip : 21.2.4
setuptools : 46.0.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10
IPython : 7.8.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.1.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : 1.3.5
tables : None
tabulate : 0.8.3
xarray : None
xlrd : 1.2.0
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: