Open liudengfeng opened 4 years ago
Hi,
thanks for your report. This stopped working with release 1.0 as described in https://pandas.pydata.org/docs/user_guide/indexing.html#indexing-deprecate-loc-reindex-listlike. This is more or less translated into animals.loc[[1,-1,2]].
But we could maybe clarify the documentation here?
Edit: Actually that did not work before 1.0 either.
Hi,
Python read the data line by line, in the second animal data-frame that particular (-1) index is not present that's why it's not returning any value.
You can try
import pandas as pd animals = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama'],index=[-1,0,1,2,3]) print(animals.get([1,-1,2]))
animals = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama']) print(animals.get([1,2]))
print(animals.get([1,2]))
[ ] 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.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Problem description
[this should explain why the current behaviour is a problem and why the expected output is a better solution]
Expected Output
If you mix existing labels with non-existent labels, at least need to return the corresponding results of the existing labels?
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 2a7d3326dee660824a8433ffd01065f8ac37f7d6 python : 3.8.5.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.18362 machine : AMD64 processor : Intel64 Family 6 Model 142 Stepping 12, GenuineIntel byteorder : little LC_ALL : None LANG : None LOCALE : Chinese (Simplified)_China.936
pandas : 1.1.2 numpy : 1.19.1 pytz : 2020.1 dateutil : 2.8.1 pip : 20.2.2 setuptools : 49.6.0.post20200814 Cython : 0.29.21 pytest : 6.0.1 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : 4.5.2 html5lib : 1.1 pymysql : None psycopg2 : None jinja2 : 2.11.2 IPython : 7.18.1 pandas_datareader: None bs4 : 4.9.1 bottleneck : 1.3.2 fsspec : 0.8.0 fastparquet : None gcsfs : None matplotlib : 3.3.1 numexpr : 2.7.1 odfpy : None openpyxl : None pandas_gbq : None pyarrow : 1.0.1 pytables : None pyxlsb : None s3fs : None scipy : 1.5.2 sqlalchemy : 1.3.19 tables : 3.6.1 tabulate : None xarray : None xlrd : 1.2.0 xlwt : None numba : None
[paste the output of
pd.show_versions()
here leaving a blank line after the details tag]