How to produce a scatter plot using timestamps
?
Below is an example but I get an error ValueError: First argument must be a sequence
import pandas as pd
import matplotlib.pyplot as plt
d = ({
'A' : ['08:00:00','08:10:00'],
'B' : ['1','2'],
})
df = pd.DataFrame(data=d)
fig = plt.figure()
x = df['A']
y = df['B']
plt.scatter(x,y)
If I convert the timestamps to total seconds it works:
df['A'] = pd.to_timedelta(df['A'], errors="coerce").dt.total_seconds()
But I'd like 24hr time to be on the x-axis, rather than total seconds.