diff --git a/cookbook/Chapter 4 - Find out on which weekday people bike the most with groupby and aggregate.ipynb b/cookbook/Chapter 4 - Find out on which weekday people bike the most with groupby and aggregate.ipynb index 186a7094b..212fd35d1 100644 --- a/cookbook/Chapter 4 - Find out on which weekday people bike the most with groupby and aggregate.ipynb +++ b/cookbook/Chapter 4 - Find out on which weekday people bike the most with groupby and aggregate.ipynb @@ -348,7 +348,7 @@ } ], "source": [ - "berri_bikes.loc[:,'weekday'] = berri_bikes.index.weekday\n", + "berri_bikes['weekday'] = berri_bikes.index.weekday\n", "berri_bikes[:5]" ] }, @@ -367,7 +367,7 @@ "\n", "Dataframes have a `.groupby()` method that is similar to SQL groupby, if you're familiar with that. I'm not going to explain more about it right now -- if you want to to know more, [the documentation](http://pandas.pydata.org/pandas-docs/stable/groupby.html) is really good.\n", "\n", - "In this case, `berri_bikes.groupby('weekday').aggregate(sum)` means \"Group the rows by weekday and then add up all the values with the same weekday\"." + "In this case, `berri_bikes.groupby('weekday').sum()` means \"Group the rows by weekday and then add up all the values with the same weekday\"." ] }, { @@ -454,7 +454,7 @@ } ], "source": [ - "weekday_counts = berri_bikes.groupby('weekday').aggregate(sum)\n", + "weekday_counts = berri_bikes.groupby('weekday').sum()\n", "weekday_counts" ] }, @@ -634,10 +634,10 @@ " index_col='Date')\n", "# Add the weekday column\n", "berri_bikes = bikes[['Berri 1']].copy()\n", - "berri_bikes.loc[:,'weekday'] = berri_bikes.index.weekday\n", + "berri_bikes['weekday'] = berri_bikes.index.weekday\n", "\n", "# Add up the number of cyclists by weekday, and plot!\n", - "weekday_counts = berri_bikes.groupby('weekday').aggregate(sum)\n", + "weekday_counts = berri_bikes.groupby('weekday').sum()\n", "weekday_counts.index = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']\n", "weekday_counts.plot(kind='bar')" ]