Skip to content

Commit c3351b4

Browse files
Merge pull request #305 from UBC-DSCI/reset-index
Minor improvements to reset index usage
2 parents 376bac2 + 790f749 commit c3351b4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

source/wrangling.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,14 +1422,14 @@ Non-Aboriginal, and Official) are spoken at home in different regions, we would
14221422
list including `region` and `category` to `groupby`.
14231423

14241424
```{code-cell} ipython3
1425-
region_lang.groupby(["region", "category"])["most_at_home"].agg(["min", "max"])
1425+
region_lang.groupby(["region", "category"])["most_at_home"].agg(["min", "max"]).reset_index()
14261426
```
14271427

14281428
You can also ask for grouped summary statistics on the whole data frame.
14291429

14301430
```{code-cell} ipython3
14311431
:tags: ["output_scroll"]
1432-
region_lang.groupby("region").agg(["min", "max"])
1432+
region_lang.groupby("region").agg(["min", "max"]).reset_index()
14331433
```
14341434

14351435
If you want to ask for only some columns, for example
@@ -1459,7 +1459,7 @@ this approach always works.
14591459

14601460
```{code-cell} ipython3
14611461
:tags: ["output_scroll"]
1462-
region_lang.groupby("region")[["most_at_home", "most_at_work", "lang_known"]].max()
1462+
region_lang.groupby("region")[["most_at_home", "most_at_work", "lang_known"]].max().reset_index()
14631463
```
14641464

14651465
To see how many observations there are in each group,

0 commit comments

Comments
 (0)