pandas - Time Series Plot Python -
i using pandas , want make time series plot. have dataframe, , want plot date on x-axis number of units on y-axis. assuming need convert date object datetime before can make plot.
df1_99.dtypes date object store_nbr int64 units int64 tavg int64 preciptotal float64 dtype: object df1_99 date store_nbr units tavg preciptotal 101885 2014-10-13 1 2 49 0.00 101996 2014-10-14 1 1 67 0.00 102107 2014-10-15 1 0 70 0.00 102218 2014-10-16 1 0 67 0.87 102329 2014-10-17 1 3 65 0.01
as dates strings can use to_datetime
convert datetime objects:
in [4]: df['date'] = pd.to_datetime(df['date']) df.info() <class 'pandas.core.frame.dataframe'> int64index: 5 entries, 101885 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 plot this:
df.plot(x='date', y='units')