I'm a little addicted, so make a note
I want to plot sensor data timed in Unixtime with time on the horizontal axis and sensor data on the vertical axis.
As usual
import pandas as pd
import pandas.tseries.offsets as offsets
Data = pd.read_csv('data.csv')
Data['timestamp'] = pd.to_datetime(Data['timestamp'], unit="ms")
Data['timestamp'] += offsets.Hour(9)
Read the data with
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
x = Data['timestamp']
y = Data['sensor']
ax.plot(x, y)
I said. .. ..
matplotlib OverflowError: signed integer is greater than maximum
It seems that an OverflowError occurred because timestamp
was a format that included up to milliseconds in UNIXTIME.
http://stackoverflow.com/questions/11376080/plot-numpy-datetime64-with-matplotlib As written in.
x = Data['timestamp'].astype(datetime)
Like, it was drawn when the type was converted with .astype (datetime)
. Congratulations.
Recommended Posts