Skip to content

Commit 579530d

Browse files
committed
added note about size() groupby method
1 parent 07a4685 commit 579530d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Open_Lab_4_exploratory_analysis_with_pandas/Open_Lab_4_exploratory_analysis_with_pandas.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@
271271
"cell_type": "markdown",
272272
"metadata": {},
273273
"source": [
274-
"You can also use `groupby()` to group data by multiple variables. We will create a hierarchical grouping of `OilPainting` and then `Gender` to see the counts of oil paintings by different genders. We can use `.mean()` to find the average for each of those subcategories, or we can use `.size()` to find counts of each category."
274+
"You can also use `groupby()` to group data by multiple variables. We will create a hierarchical grouping of `OilPainting` and then `Gender` to see the counts of oil paintings by different genders. We can use `.mean()` to find the average for each of those subcategories, or we can use `.size()` to find counts of each category.\n",
275+
"\n",
276+
"Note: the `.size()` method used in this example is a function for groupby objects. This method will return the number of items in each group. The documentation for this method can be found [here](https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.DataFrameGroupBy.size.html). The pandas DataFrame `.size` property (documentation [here](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.size.html)) returns the number of elements."
275277
]
276278
},
277279
{

Open_Lab_4_exploratory_analysis_with_pandas/filled_Open_Lab_4_exploratory_analysis_with_pandas.ipynb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2994,7 +2994,9 @@
29942994
"cell_type": "markdown",
29952995
"metadata": {},
29962996
"source": [
2997-
"You can also use `groupby()` to group data by multiple variables. We will create a hierarchical grouping of `OilPainting` and then `Gender` to see the counts of oil paintings by different genders. We can use `.mean()` to find the average for each of those subcategories, or we can use `.size()` to find counts of each category."
2997+
"You can also use `groupby()` to group data by multiple variables. We will create a hierarchical grouping of `OilPainting` and then `Gender` to see the counts of oil paintings by different genders. We can use `.mean()` to find the average for each of those subcategories, or we can use `.size()` to find counts of each category.\n",
2998+
"\n",
2999+
"Note: the `.size()` method used in this example is a function for groupby objects. This method will return the number of items in each group. The documentation for this method can be found [here](https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.DataFrameGroupBy.size.html). The pandas DataFrame `.size` property (documentation [here](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.size.html)) returns the number of elements."
29983000
]
29993001
},
30003002
{
@@ -3021,7 +3023,7 @@
30213023
"source": [
30223024
"# Group the data by OilPainting and then Gender \n",
30233025
"# find the counts of subcategories with .size()\n",
3024-
"paintings.groupby(['OilPainting', 'Gender']).size()"
3026+
"paintings.groupby(['OilPainting', 'Gender']).value_counts()"
30253027
]
30263028
},
30273029
{

0 commit comments

Comments
 (0)