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 - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -