Skip to content

BUG: Different behaviour for index after assign dataframe new column by series #36527

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

Closed
2 of 3 tasks
arybin93 opened this issue Sep 21, 2020 · 5 comments · Fixed by #36532
Closed
2 of 3 tasks

BUG: Different behaviour for index after assign dataframe new column by series #36527

arybin93 opened this issue Sep 21, 2020 · 5 comments · Fixed by #36532
Labels
Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@arybin93
Copy link

  • 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

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
]

@arybin93 arybin93 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 21, 2020
@jorisvandenbossche jorisvandenbossche added Regression Functionality that used to work in a prior pandas version and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 21, 2020
@jorisvandenbossche jorisvandenbossche added this to the 1.1.3 milestone Sep 21, 2020
@jorisvandenbossche
Copy link
Member

@arybin93 thanks for the clear report. That's indeed a regression in pandas 1.1.2 compared to 1.1.1 / 1.0

@jorisvandenbossche
Copy link
Member

Based on the title of the PR, probably related to #36141 cc @Dr-Irv

@Dr-Irv
Copy link
Contributor

Dr-Irv commented Sep 21, 2020

@jorisvandenbossche You are right. Pushed a PR that should correct that

@arybin93
Copy link
Author

So it looks that release notes for 1.1.2 contain fixed bug #31368

Release notes

Bug when setting empty DataFrame column to a Series in preserving name of index in frame (GH31368)

But in reality not and changes will in 1.1.3, is it so?

@Dr-Irv
Copy link
Contributor

Dr-Irv commented Sep 22, 2020

@arybin93 The fix in 1.1.2 that fixed #31368 created the issue you have reported here, which is now addressed in #36532 and is planned for 1.1.3, so that both #31368 and this issue are resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants