Time Series Plot Python
I am using pandas and I want to make a time series plot. I have this dataframe, and I want to plot the date on the x-axis with the number of units on the y-axis. I am assuming I ne
Solution 1:
As your dates are strings you can use to_datetime
to convert to datetime objects:
In [4]:
df['date'] = pd.to_datetime(df['date'])
df.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 5 entries, 101885 to 102329
Data columns (total 5 columns):
date 5 non-null datetime64[ns]
store_nbr 5 non-null int64
units 5 non-null int64
tavg 5 non-null int64
preciptotal 5 non-null float64
dtypes: datetime64[ns](1), float64(1), int64(3)
memory usage: 240.0 bytes
You can then plot this:
df.plot(x='date', y='units')
Post a Comment for "Time Series Plot Python"