I am currently trying to plot simple integer values against time using plotly.express, a sample of the data looks like this:
df =
TagTimeStamp COP
0 2019-01-08 01:00:00 2.289827
1 2019-01-08 02:00:00 2.276451
2 2019-01-08 03:00:00 2.249055
3 2019-01-08 04:00:00 2.260732
4 2019-01-08 05:00:00 2.256685
... ... ...
42390 2020-05-29 07:00:00 4.186115
42391 2020-05-29 08:00:00 4.186170
42392 2020-05-29 09:00:00 4.186234
42393 2020-05-29 10:00:00 4.186312
42394 2020-05-29 11:00:00 4.186396
Trying to plot:
import plotly.express as px
fig = px.line(df, x="TagTimeStamp", y="COP")
fig.show()
The figure shown:
I am expecting something like this, shown in the answer of that post.
EDIT: After sorting the dates and averaging values by month, I have a credible output:
import plotly.express as px
import pandas as pd
d = df.sort_values(by='TagTimeStamp', ascending = False)
per_month = d.set_index('TagTimeStamp').groupby(pd.Grouper(freq='M'))['COP'].mean()
x = per_month.index
y = per_month.values
fig = px.line(d, x=x, y=y)
fig.update_xaxes(title="Month and Year")
fig.update_yaxes(title="COP")
fig.show()
Apologies.