Skip to content

BUG: df reassignment following reorder_categories changed behavior in 1.1.0rc0 #35369

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
MaozGelbart opened this issue Jul 21, 2020 · 2 comments · Fixed by #35271
Closed
2 of 3 tasks

BUG: df reassignment following reorder_categories changed behavior in 1.1.0rc0 #35369

MaozGelbart opened this issue Jul 21, 2020 · 2 comments · Fixed by #35271
Labels
Bug Categorical Categorical Data Type Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@MaozGelbart
Copy link

MaozGelbart commented Jul 21, 2020

  • 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

import pandas as pd

h = pd.Series(list("mn")).astype("category")
df = pd.DataFrame({"h":h})

df.h = df.h.cat.reorder_categories(["n", "m"])
print(df.h.cat.categories)

h = h.cat.reorder_categories(["n","m"])
print(h.cat.categories)

Problem description

Output with 1.1.0rc0:

Index(['m', 'n'], dtype='object')
Index(['n', 'm'], dtype='object')

The assignment of the reordered series back into the dataframe seems to remove the new order. This has changed from 1.0.5 but I could not find a note on this under the release notes.

Expected Output

As with 1.0.5:

Index(['n', 'm'], dtype='object')
Index(['n', 'm'], dtype='object')

Output of pd.show_versions()

INSTALLED VERSIONS

commit : bfac136
python : 3.8.3.final.0
python-bits : 64
OS : Darwin
OS-release : 19.5.0
Version : Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.UTF-8

pandas : 1.1.0rc0
numpy : 1.19.0
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 49.2.0.post20200712
Cython : None
pytest : 5.4.3
hypothesis : None
sphinx : 2.3.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.15.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.0
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None

@MaozGelbart MaozGelbart added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 21, 2020
@simonjayhawkins
Copy link
Member

Thanks @MaozGelbart for the report.

it appears #32831 resulted in this change of behaviour.

d427335 is the first bad commit
commit d427335
Author: jbrockmendel [email protected]
Date: Sat Mar 21 14:00:30 2020 -0700

BUG: ExtensionBlock.set not setting values inplace (#32831)

marking as regression for now, while further investigate.

cc @jbrockmendel

@simonjayhawkins simonjayhawkins added Categorical Categorical Data Type Regression Functionality that used to work in a prior pandas version and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 22, 2020
@simonjayhawkins simonjayhawkins added this to the 1.1 milestone Jul 22, 2020
simonjayhawkins added a commit to jorisvandenbossche/pandas that referenced this issue Jul 22, 2020
@TomAugspurger
Copy link
Contributor

Closing as a duplicate of #33457

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Categorical Categorical Data Type 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