Reputation: 1184
I have a csv file that looks like such:
df = pd.read_csv('book1.csv', header=1)
Index Date Time DEMAND
0 2005-03-01 06:30:00 1
1 2005-03-01 06:45:00 2
2 2005-03-01 07:00:00 4
3 2005-03-01 07:15:00 0
4 2005-03-01 07:30:00 10
5 2005-03-01 07:45:00 13
I would like to plot this, but when I call df.plot(), I get the error:
df.plot()
ValueError: view limit minimum -36601.34583333333 is less than 1 and is an invalid Matplotlib date value. This often happens if you pass a non-datetime value to an axis that has datetime units
I have also tried creating my time series this way:
pd.Series(data=df['DEMAND'], index=df['Date Time'])
But the result is that the data turns null:
Date Time
2005-03-01 06:30:00 NaN
2005-03-01 06:45:00 NaN
2005-03-01 07:00:00 NaN
2005-03-01 07:15:00 NaN
2005-03-01 07:30:00 NaN
2005-03-01 07:45:00 NaN
2005-03-01 08:00:00 NaN
2005-03-01 08:15:00 NaN
2005-03-01 08:30:00 NaN
I'm looking for
1)advice on why these methods are failing, and/or
2)alternative way to get my desired result.
Thanks!
Upvotes: 1
Views: 818
Reputation: 1184
I did come up with one solution:
x = df['Date Time']
y = df['DEMAND']
plt.plot(x,y)
still interested in figuring out why I'm having issues with my methods.
Upvotes: 1