Skip to content

Commit d292088

Browse files
committed
Update size.md
1 parent 6a8b3f8 commit d292088

File tree

1 file changed

+8
-8
lines changed
  • content/pandas/concepts/groupby/terms/size

1 file changed

+8
-8
lines changed

content/pandas/concepts/groupby/terms/size/size.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ CatalogContent:
1212
- 'paths/data-science'
1313
---
1414

15-
The **`groupby().size()`** method in pandas returns the number of rows or elements in each group created by the `groupby()` function. It provides a quick way to determine group sizes without applying an aggregation function.
15+
The **`size()`** method in pandas returns the number of rows or elements in each group created by the `groupby()` [function](https://www.codecademy.com/resources/docs/pandas/built-in-functions). It provides a quick way to determine group sizes without applying an aggregation function.
1616

1717
## Syntax
1818

@@ -22,15 +22,15 @@ DataFrameGroupBy.size()
2222

2323
**Parameters:**
2424

25-
The `size()` method does not take any parameters.
25+
The `size()` method doesn't take any parameters.
2626

2727
**Return value:**
2828

2929
The `size()` method returns a Series containing the size (row count) of each group created by `groupby()`.
3030

31-
## Example 1: Counting rows by group
31+
## Example 1: Counting Rows by Group
3232

33-
In this example, a DataFrame of employees is grouped by their department, and `size()` counts how many employees belong to each department:
33+
In this example, a [DataFrame](https://www.codecademy.com/resources/docs/pandas/dataframe) of employees is grouped by their department, and `size()` counts how many employees belong to each department:
3434

3535
```py
3636
import pandas as pd
@@ -55,7 +55,7 @@ IT 2
5555
dtype: int64
5656
```
5757

58-
## Example 2: Using multiple grouping columns
58+
## Example 2: Using Multiple Grouping Columns
5959

6060
In this example, `size()` counts the number of members in each combination of team and shift within a dataset:
6161

@@ -85,7 +85,7 @@ C Day 1
8585
dtype: int64
8686
```
8787

88-
## Codebyte Example: Counting transactions per product
88+
## Codebyte Example: Counting Transactions Per Product
8989

9090
In this example, `size()` is used to count how many sales transactions occurred for each product in a store dataset:
9191

@@ -103,11 +103,11 @@ print(counts)
103103

104104
## Frequently Asked Questions
105105

106-
### 1. What is the pandas groupby size method?
106+
### 1. What is the pandas `groupby().size()` method?
107107

108108
`groupby().size()` returns the number of rows in each group created by `groupby()`.
109109

110-
###2. What is the purpose of `groupby()` in pandas?
110+
### 2. What is the purpose of `groupby()` in pandas?
111111

112112
`groupby()` splits data into groups based on selected column values to enable aggregation and summarization.
113113

0 commit comments

Comments
 (0)