With Python 2.7 and notebook, I am trying to display a simple Series that looks like:
year
2014 1
2015 3
2016 2
Name: mySeries, dtype: int64
I would like to:
- Name the second column, I cant seem to succeed with
s.columns = ['a','b']. How do we do this? - Plot the result where the years are written as such. When I run
s.plot()I get the years as x, which is good but I get weird values:
Thanks for the help!
If it helps, this series comes from the following code:
df = pd.read_csv(file, usecols=['dates'], parse_dates=True)
df['dates'] = pd.to_datetime(df['date'])
df['year'] = pd.DatetimeIndex(df['dartes']).year
df
which gives me:
dates year
0 2015-05-05 14:21:00 2015
1 2014-06-06 14:22:00 2014
2 2015-05-05 14:14:00 2015
On which I do:
s = pd.Series(df.groupby('year').size())

Seriesso by definition it's1-Dso you can't assign multiple values tocolumns