1
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 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.

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?

Thanks!

Jignasha Royala
  • 1,032
  • 10
  • 27

1 Answers1

0

(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:

enter image description here

And you say you'd like to use 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.

vestland
  • 55,229
  • 37
  • 187
  • 305