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

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -