DataFrame.iplot doesn't work with TimeDeltaIndex

Hello,

I noticed that DataFrame.iplot doesn’t work with TimeDeltaIndex.

Here is code

import pandas as pd
pd.set_option("max_rows", 10)  # affichage limité à 10 lignes

# import plotly.plotly as py
# import plotly.graph_objs as go
from plotly.offline import iplot, init_notebook_mode

import cufflinks as cf
cf.go_offline(connected=True)
init_notebook_mode(connected=True)

N = 3
rng = pd.timedelta_range(start="0h", freq="15min", periods=3)
df = pd.DataFrame({"a": [1,2,3], "b": [1,3,2], "c": [4,5,6]}, index=rng)
# df.index = df.index.total_seconds() / 60  # convert TimeDelta to minutes
df.iplot()

and a screenshot

You can notice that x-axis is not displayed correctly.

A workaround can be to convert to minutes using

df.index = df.index.total_seconds() / 60

or to Timestamp

df.index = df.index + pd.to_datetime(0)

Kind regards

Issue opened at https://github.com/santosjorge/cufflinks/issues/188

plotly.py issue https://github.com/plotly/plotly.py/issues/799,
-Jon

Well done! I didn’t recall my own issue.

1 Like