-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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: xs not working with slice #35301
Comments
+1 that this should work. I've checked that this is a problem on the 1.1 master Output of pd.versions()INSTALLED VERSIONS ------------------ commit : b59831e python : 3.8.3.final.0 python-bits : 64 OS : Linux OS-release : 5.4.0-40-generic Version : #44-Ubuntu SMP Tue Jun 23 00:01:04 UTC 2020 machine : x86_64 processor : byteorder : little LC_ALL : C.UTF-8 LANG : C.UTF-8 LOCALE : en_US.UTF-8pandas : 1.1.0.dev0+2129.gb59831e97 I think the fix will involve changing Lines 3415 to 3574 in b687cd4
or possibly some of the methods that chunk refers to. Happy to do a PR on this unless @wiso you'd like to? |
@arw2019 thanks for checking. I am just a user, will take ages to understand where to put my hands inside the code. |
ok! In that case I'll take it |
hi,could I fix this bug?I have fix this issue In my own computer! |
Yeah go for it |
fix bugs be metioned on issue pandas-dev#35301
fix bugs be metioned on issue pandas-dev#35301
fix bugs be metioned on issue pandas-dev#35301
xs is intended for scalar lookups |
@jbrockmendel ahh thanks! In fairness that is stated in the DataFrame.xs doc @wiso Do you think it's worth adding a clarification there? If yes I'll do a PR for that Barring that we can probably close this |
maybe a better error message; something like |
I think it's a good idea! |
Sorry, I am not sure to understand everything. Are you saying I can't pass a pd.IndexSlice to xs? Why not? It is working in one case and it is very useful. By the way in general, I am searching for an alternative to |
the difference between
so at present, the working case is not documented, tested or supported. I would therefore say, the issue is not a bug, but could maybe be an enhancement if it makes sense. |
I see, so if it is not supported I guess it should trigger an error if the user try to pass As I said one big difference between |
Agreed. There has been some previous discussion on deprecating so rather than enhancing I'll leave this labelled as |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
Problem description
also similar code produce the same problem (
df.xs(('A1', slice(None)))
). Strangely this works:Output of
pd.show_versions()
pandas : 1.0.5
numpy : 1.19.0
pytz : 2019.2
dateutil : 2.7.5
pip : 20.1.1
setuptools : 41.6.0
Cython : 0.29.15
pytest : 4.0.0
hypothesis : None
sphinx : 3.1.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.4.0
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10
IPython : 7.16.1
pandas_datareader: 0.8.0
bs4 : 4.7.1
bottleneck : 1.2.1
fastparquet : None
gcsfs : None
lxml.etree : 4.4.0
matplotlib : 3.2.2
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 4.0.0
pyxlsb : None
s3fs : 0.4.2
scipy : 1.5.1
sqlalchemy : None
tables : 3.5.2
tabulate : 0.8.5
xarray : 0.12.1
xlrd : 1.2.0
xlwt : 1.1.2
xlsxwriter : None
numba : 0.48.0
The text was updated successfully, but these errors were encountered: