停止以图形方式将日期序列表示为日期时间和时间戳数据的秒数

时间:2019-01-27 19:28:58

标签: pandas plotly

我正在Plotly尝试一些我想使用Dash显示的前端视觉效果。它似乎很有用,但是我在日期时间问题上陷入了困境。具体来说,当我传递包含时间戳或日期时间信息的熊猫数据框时,秒的存在意味着时间轴使用科学计数法以秒为单位显示时间。例如,请参见下面链接上的图表(以图解方式生成在线图像): enter image description here 我的代码非常简单;见下文:

import plotly.plotly as py
import plotly.graph_objs as go
import pandas as pd
from datetime import datetime

info = pd.read_pickle('filepath.pkl')

trace = go.Scatter(x = info['publication_time'], y = info['jsd'], mode = 'lines', name = 'jsd')

data = [trace]

py.plot(data, filename = 'time-series-simple', auto_open=True)

请注意,我可以通过使用date()转换“ publication_time”值来“解决”此问题,如下所示。 enter image description here 但是当我这样做时,我会丢失日历日期的所有时间信息,这对于我的数据而言是个问题。

任何帮助表示赞赏!

编辑:示例数据供说明:

df = pd.DataFrame({'Time': [Timestamp('2013-06-17 22:00:44'),
 Timestamp('2013-08-06 21:31:46'),
 Timestamp('2013-08-14 00:03:40'),
 Timestamp('2014-01-23 19:16:02'),
 Timestamp('2014-02-03 22:07:19'),
 Timestamp('2014-04-08 16:34:29'),
 Timestamp('2014-04-24 00:00:00'),
 Timestamp('2014-07-24 10:00:00'),
 Timestamp('2014-10-24 13:10:41')], 'Value':[0.9259890294026274,
 0.8475729796693869,
 0.811830101974202,
 0.7727937137247451,
 0.6815034448835853,
 0.41908808936508635,
 0.6908772808127566,
 0.9425539823548483,
 0.7876344379636819]})

0 个答案:

没有答案