Skip to content

REGR: Sorted pandas series is not plotted in the expected order in pandas 1.2.0 #38865

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
GajjarMihir opened this issue Dec 31, 2020 · 7 comments · Fixed by #39491
Closed
2 of 3 tasks

REGR: Sorted pandas series is not plotted in the expected order in pandas 1.2.0 #38865

GajjarMihir opened this issue Dec 31, 2020 · 7 comments · Fixed by #39491
Assignees
Labels
Needs Tests Unit test(s) needed to prevent regressions Regression Functionality that used to work in a prior pandas version Visualization plotting
Milestone

Comments

@GajjarMihir
Copy link

GajjarMihir commented Dec 31, 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

Note: The code was executed in Jupyter notebook.

import pandas as pd
print(pd.__version__)
d = {'col1': [4,2,3,1]}
df = pd.DataFrame(data=d)
df['col1'].sort_values().plot(kind='bar')

Problem description

In Pandas 1.2.0, the sorted values are not plotted in the correct order. Note that df['col1'].sort_values() does return sorted values.

pandas 1.2.0

Expected Output

In Pandas 1.1.5, this works as expected. This might be the case in older versions of pandas as well.

pandas 1.1.5

Output of pd.show_versions()

INSTALLED VERSIONS

commit : b5958ee
python : 3.8.5.final.0
python-bits : 64
OS : Darwin
OS-release : 20.2.0
Version : Darwin Kernel Version 20.2.0: Wed Dec 2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_CA.UTF-8
LOCALE : en_CA.UTF-8

pandas : 1.1.5
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.4
setuptools : 50.3.0.post20201006
Cython : 0.29.21
pytest : 6.1.1
hypothesis : 5.37.4
sphinx : 3.2.1
blosc : None
feather : None
xlsxwriter : 1.3.7
lxml.etree : 4.6.1
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.18.1
pandas_datareader: None
bs4 : 4.9.3
bottleneck : 1.3.2
fsspec : 0.8.3
fastparquet : None
gcsfs : None
matplotlib : 3.3.2
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.5
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.0
sqlalchemy : 1.3.19
tables : 3.6.1
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.51.2

@GajjarMihir GajjarMihir added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 31, 2020
@jreback
Copy link
Contributor

jreback commented Dec 31, 2020

pls edit the title to reflect the issue

@GajjarMihir GajjarMihir changed the title BUG: BUG: Sorted pandas series is not plotted in the expected order in pandas 1.2.0 Dec 31, 2020
@GajjarMihir
Copy link
Author

pls edit the title to reflect the issue

Just fixed this. Thanks :)

@mzeitlin11
Copy link
Member

mzeitlin11 commented Dec 31, 2020

Thanks for the report @GajjarMihir! This is a regression caused by #28733. Other regression from this was (#38736)

@mzeitlin11 mzeitlin11 added Regression Functionality that used to work in a prior pandas version Visualization plotting and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 31, 2020
@simonjayhawkins simonjayhawkins added this to the 1.2.1 milestone Jan 1, 2021
@simonjayhawkins simonjayhawkins changed the title BUG: Sorted pandas series is not plotted in the expected order in pandas 1.2.0 REGR: Sorted pandas series is not plotted in the expected order in pandas 1.2.0 Jan 1, 2021
@simonjayhawkins
Copy link
Member

cc @nrebena

@nonZero
Copy link

nonZero commented Jan 14, 2021

Another simple reproduction of this undocumented change in behavior:

import pandas as pd
pd.Series([10, 50, 20, 30], index=[1910, 1920, 1980, 1950]).plot.bar(title=pd.__version__);

image

image

@simonjayhawkins simonjayhawkins added the Needs Tests Unit test(s) needed to prevent regressions label Jan 18, 2021
@simonjayhawkins
Copy link
Member

This is a regression caused by #28733.

#28733 has been reverted. needs tests to prevent regressions.

@simonjayhawkins simonjayhawkins modified the milestones: 1.2.1, Contributions Welcome Jan 18, 2021
@avinashpancham
Copy link
Contributor

take

@jreback jreback modified the milestones: Contributions Welcome, 1.3 Jan 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Tests Unit test(s) needed to prevent regressions Regression Functionality that used to work in a prior pandas version Visualization plotting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants