[英]Fitting timedelta on plotly y axis
Date Light Time_difference Time_analysis
0 2018-11-17 00:00:00 5000.0 0 days 00:00:00 fine
1 2018-11-17 00:03:00 5000.0 0 days 00:03:00 fine
2 2018-11-17 00:06:00 5000.0 0 days 00:03:00 fine
3 2018-11-17 00:09:00 5000.0 0 days 00:03:00 fine
4 2018-11-17 00:12:00 5000.0 0 days 00:03:00 fine
482785 2021-02-22 23:59:56 634.4 0 days 00:00:00 fine
482786 2021-02-22 23:59:57 574.3 0 days 00:00:00 fine
482787 2021-02-22 23:59:58 598.9 0 days 00:00:00 fine
482788 2021-02-22 23:59:59 676.9 0 days 00:00:00 fine
482789 2021-02-23 00:00:00 5000.0 0 days 00:03:00 fine
I'm trying to use plotly to plot the dataframe, and I would like to plot a graph with my Date column on the x axis, and Time_difference on the y axis, with the Time_analysis column as the key/colour code. I'm trying to use plotly to plot the dataframe, and I would like to plot a graph with my Date column on the x axis, and Time_difference on the y axis, with the Time_analysis column as the key/colour code. I tried the following code, but unfortunately, the format of the Time_difference column doesn't come out the way I'd like it to, instead of '0 days 00:00:00', it reads '1 x 10 to the power of 15', for example.
我尝试了以下代码,但不幸的是,Time_difference 列的格式并没有按照我想要的方式出现,而不是“0 天 00:00:00”,而是“1 x 10 的幂”例如,15'。
fig = px.line(closer, x="Date", y="Time_difference", color="Time_analysis", labels={"Time_analysis": "fine", "Time_analysis": "gaps"}) fig.show()
Is there a way I can change the format of Time_difference so that it reads '0 days 00:00:00', for example?例如,有没有办法可以更改 Time_difference 的格式,使其显示为“0 天 00:00:00”?
Thanks!谢谢!
(answer in progress) (回答中)
The way your question currently stands this problem is not reproducible.您的问题目前代表这个问题的方式是不可重现的。 I've picked up a piece of your data like this:
我已经收集了您的一些数据,如下所示:
closer = pd.DataFrame({'Date': {0: '2018-11-17 00:00:00',
1: '2018-11-17 00:03:00',
2: '2018-11-17 00:06:00'},
'Light': {0: 5000.0, 1: 5000.0, 2: 5000.0},
'Time_difference': {0: '0 days 00:00:00',
1: '0 days 00:03:00',
2: '0 days 00:03:00'},
'Time_analysis': {0: 'fine', 1: 'fine', 2: 'fine'}})
And running your code produces this plot:运行你的代码会产生这个 plot:
And you say you'd like to use the Time_analysis column as the key/colour code.
您说您想使用
the Time_analysis column as the key/colour code.
But it seems to me that you haven't produced a data sample that makes this possible.但在我看来,您还没有制作出使这成为可能的数据样本。 If that's the case, please provide a new dataset in the manner described here .
如果是这种情况,请按照此处描述的方式提供新数据集。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.