I am observing some strange behavior when plotting a column from my Pandas dataframe.
My data looks like the following:
value timestamp
0 67 2023-01-04T05:17:49+00:00
1 67 2023-01-04T05:27:57+00:00
2 66 2023-01-04T05:28:01+00:00
3 81 2023-01-04T05:28:19+00:00
4 67 2023-01-04T05:33:02+00:00
... ... ...
102 73 2023-01-04T22:22:04+00:00
103 76 2023-01-04T22:26:59+00:00
104 77 2023-01-04T22:27:12+00:00
105 75 2023-01-04T22:27:13+00:00
106 73 2023-01-04T22:32:35+00:00
Now comes the fun part:
I convert the timestamp column to a pandas datetime object with: df['timestamp_dt'] = pd.to_datetime(df['timestamp'])
. I create a new column so you can observe the behavior.
I then plot both of the column with seaborn:
#Plot where timestamp is "String"
sns.lineplot(data=df, x="timestamp", y="bpm")
plt.show()
#Plot where timestamp is "dattime object"
sns.lineplot(data=df, x="timestamp_dt", y="bpm")
plt.show()
As you can see, converting the timestamps into datetime object results in a weird behavior of the graph.
Why is this and how can I convert the timestamps and have a normal looking graph?
I have looked at the following solution, which suggests adding a format. However I was not able to solve it that way.