python - Trouble plotting pandas DataFrame -


i have pandas dataframe has 2 columns 1 of columns list of dates in format: '4-dec-14' other column list of numbers. want plot graph dates on x-axis , numbers correspond date on y-axis. either scatter plot or line graph. trying follow tutorial on matplotlib http://matplotlib.org/users/recipes.html 'fixing common date annoyances' not accept date format. when try using plot function returns error: valueerror: invalid literal float(): 4-dec-14. how change date format work. or there other way can plot dataframe. thanks

you should first convert strings in date column, actual datetime values:

df['date'] = pd.to_datetime(df['date']) 

then can plot it, either setting date index:

df = df.set_index('date') df['y'].plot() 

or specifying x , y in plot:

df.plot(x='date', y='y') 

Comments

Popular posts from this blog

javascript - ScrollTo Effect (href to div) -

javascript - ng-class not responding to change in model in Angular? -

javascript - document.registerElement extending HTMLInputElement prototype while using custom tag name to avoid implicit browser style -