Skip to content

Commit

Permalink
Merge pull request #305 from UBC-DSCI/reset-index
Browse files Browse the repository at this point in the history
Minor improvements to reset index usage
  • Loading branch information
trevorcampbell authored Nov 12, 2023
2 parents 376bac2 + 790f749 commit c3351b4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions source/wrangling.md
Original file line number Diff line number Diff line change
Expand Up @@ -1422,14 +1422,14 @@ Non-Aboriginal, and Official) are spoken at home in different regions, we would
list including `region` and `category` to `groupby`.

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

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

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

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

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

To see how many observations there are in each group,
Expand Down

0 comments on commit c3351b4

Please sign in to comment.