BUG: Different behaviour for index after assign dataframe new column by series · Issue #36527 · pandas-dev/pandas (original) (raw)


Code Sample, a copy-pastable example

With pandas version 1.1.1

import pandas as pd

df = pd.DataFrame() series = pd.Series(1.23, index=pd.RangeIndex(4, name="series_index")) df['series'] = series print(df)

Problem description

With pandas version 1.1.1, output:

                         series
series_index        
0                       1.23
1                       1.23
2                       1.23
3                       1.23

We perceive index from series

With pandas version 1.1.2, output:

   series
0    1.23
1    1.23
2    1.23
3    1.23

We lost the index from series

Expected Output

I am not sure about it. Could you explain is bug or feature of the latest version?
We used to perceive index from series and it worked before.

Output of pd.show_versions()

[INSTALLED VERSIONS

commit : 2a7d332
python : 3.8.5.final.0
python-bits : 64
OS : Linux
OS-release : 4.19.104-microsoft-standard
Version : #1 SMP Wed Feb 19 06:37:35 UTC 2020
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : None
LOCALE : en_US.UTF-8
pandas : 1.1.2
numpy : 1.19.2
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.3
setuptools : 50.3.0
Cython : None
pytest : 6.0.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.8.6 (dt dec pq3 ext lo64)
jinja2 : 2.10.3
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : 1.3.19
tables : None
tabulate : 0.8.7
xarray : None
xlrd : 1.2.0
xlwt : None
numba : None
]