python - Pandas Dataframe Plot -
i trying plot time series data. dataframe looks this
[1]:index ship_date cost_amount 0 1/8/2010 34276 1 1/8/2010 12375 2 1/8/2011 12343 3 2/9/2011 15435 [2]: df1.plot(figsize(20,5))
i trying plot data reason plot doesn't have x-axis in ascending order. how plot date ascending or descending order ?
your problem (as spotted @ j richard snape) dates in fact strings it's ordered lexicographically.
you should convert datetime dtype:
df1['ship_date'] = pd.to_datetime(df1['ship_date'])
after should maintain expected order.
Comments
Post a Comment