Improve plotting Timedelta on y-axis (Timedelta string representation)
See original GitHub issueCode Sample, a copy-pastable example if possible
Following https://github.com/pandas-dev/pandas/issues/9154#issuecomment-329814404 and https://github.com/pandas-dev/pandas/issues/16953#issuecomment-329905621
import pandas as pd
from pandas.compat import StringIO
import matplotlib.pyplot as plt
dat = """c1,c2,c3
1000,2000,1500
9000,8000,1600"""
df = pd.read_csv(StringIO(dat))
#print(df)
#df.plot.bar()
#plt.show()
df = df.apply(lambda x: pd.to_timedelta(x, unit='ms'))
print(df)
df.plot.bar()
plt.show()
Displays
c1 c2 c3
0 00:00:01 00:00:02 00:00:01.500000
1 00:00:09 00:00:08 00:00:01.600000
Problem description
Y-axis should display Timedelta string representation (not integer values)
Expected Output
Output of pd.show_versions()
[paste the output of pd.show_versions()
here below this line]
pd.show_versions()
INSTALLED VERSIONS
commit: 328c7e179b72e257e27adf92a06718fd5a40473f python: 3.6.2.final.0 python-bits: 64 OS: Darwin OS-release: 16.7.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: fr_FR.UTF-8 LOCALE: fr_FR.UTF-8
pandas: 0.21.0.dev+464.g328c7e179 pytest: 3.2.1 pip: 9.0.1 setuptools: 36.4.0 Cython: 0.26 numpy: 1.13.1 scipy: None pyarrow: None xarray: None IPython: None sphinx: None patsy: None dateutil: 2.6.1 pytz: 2017.2 blosc: None bottleneck: None tables: None numexpr: None feather: None matplotlib: 2.0.2 openpyxl: None xlrd: None xlwt: None xlsxwriter: None lxml: None bs4: None html5lib: None sqlalchemy: None pymysql: None psycopg2: None jinja2: None s3fs: None fastparquet: None pandas_gbq: None pandas_datareader: None
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top GitHub Comments
@bzhphilou78 there are two workarounds:
Timedelta on y-axis still plots as milliseconds. 😬