@@ -138,7 +138,7 @@ Getting items where ``col1`` IS NOT NULL can be done with :meth:`~pandas.Series.
138
138
139
139
GROUP BY
140
140
--------
141
- In pandas, SQL's GROUP BY operations performed using the similarly named
141
+ In pandas, SQL's GROUP BY operations are performed using the similarly named
142
142
:meth: `~pandas.DataFrame.groupby ` method. :meth: `~pandas.DataFrame.groupby ` typically refers to a
143
143
process where we'd like to split a dataset into groups, apply some function (typically aggregation)
144
144
, and then combine the groups together.
@@ -163,23 +163,24 @@ The pandas equivalent would be:
163
163
164
164
tips.groupby(' sex' ).size()
165
165
166
- Notice that in the pandas code we used :meth: `~pandas.DataFrameGroupBy.size ` and not
167
- :meth: `~pandas.DataFrameGroupBy.count `. This is because :meth: `~pandas.DataFrameGroupBy.count `
168
- applies the function to each column, returning the number of ``not null `` records within each.
166
+ Notice that in the pandas code we used :meth: `~pandas.core.groupby.DataFrameGroupBy.size ` and not
167
+ :meth: `~pandas.core.groupby.DataFrameGroupBy.count `. This is because
168
+ :meth: `~pandas.core.groupby.DataFrameGroupBy.count ` applies the function to each column, returning
169
+ the number of ``not null `` records within each.
169
170
170
171
.. ipython :: python
171
172
172
173
tips.groupby(' sex' ).count()
173
174
174
- Alternatively, we could have applied the :meth: `~pandas.DataFrameGroupBy.count ` method to an
175
- individual column:
175
+ Alternatively, we could have applied the :meth: `~pandas.core.groupby. DataFrameGroupBy.count ` method
176
+ to an individual column:
176
177
177
178
.. ipython :: python
178
179
179
180
tips.groupby(' sex' )[' total_bill' ].count()
180
181
181
182
Multiple functions can also be applied at once. For instance, say we'd like to see how tip amount
182
- differs by day of the week - :meth: `~pandas.DataFrameGroupBy.agg ` allows you to pass a dictionary
183
+ differs by day of the week - :meth: `~pandas.core.groupby. DataFrameGroupBy.agg ` allows you to pass a dictionary
183
184
to your grouped DataFrame, indicating which functions to apply to specific columns.
184
185
185
186
.. code-block :: sql
0 commit comments