-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: DataFrame index name is missing after call ".loc[]" in some cases. #42188
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
Comments
I reproduced your code and I got this output
I didnt get this issue which you are facing. I am currently using pandas : 1.4.0.dev0+58.g98e22297bb version |
latest version is 1.2.4 or 1.3.0 pre-release. Your post suggests you are using 1.1.5 |
I am not able to recreate this issue on pd.version == '1.2.4'. |
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
These two dataframes are almost the same, except the last index value. However, after we select the first row with index as "a" by
.loc[]
on both dataframes, the returned dataframes are different. And the index name of the result fordf2
is missing, which is unexpected.Expected Output
The index name for the
df.loc[selected_index])
should becol_index
as it is fordf1
.Output of
pd.show_versions()
INSTALLED VERSIONS
commit : b5958ee
python : 3.6.8.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : Intel64 Family 6 Model 85 Stepping 4, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 1.1.5
numpy : 1.18.5
pytz : 2019.1
dateutil : 2.8.1
pip : 20.2.4
setuptools : 52.0.0.post20210125
Cython : 0.29.14
pytest : 6.2.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.3
IPython : 7.16.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.1.3
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 1.0.1
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
tabulate : 0.8.9
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: