REGR: Sorted pandas series is not plotted in the expected order in pandas 1.2.0 · Issue #38865 · pandas-dev/pandas (original) (raw)
- 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.
Expected Output
In Pandas 1.1.5, this works as expected. This might be the case in older versions of pandas as well.
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