Skip to content

Commit c298033

Browse files
Update source/wrangling.md
Co-authored-by: Joel Ostblom <[email protected]>
1 parent c173121 commit c298033

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

source/wrangling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,15 +1539,15 @@ you can use the more general [`apply`](https://pandas.pydata.org/docs/reference/
15391539
When we compute summary statistics or apply functions,
15401540
a new data frame or series is created. But what if we want to append that information
15411541
to an existing data frame? For example, say we wanted to compute the
1542-
maximum value in each row of the `region_lang_nums` data frame using `apply`,
1542+
maximum value in each row of the `region_lang_nums` data frame,
15431543
and to append that as an additional column of the `region_lang` data frame.
15441544
In this case, we have two options: we can either create a new column within the `region_lang` data
15451545
frame itself, or create an entirely new data frame
15461546
with the `assign` method. The first option we have seen already in earlier chapters, and is
15471547
the more commonly used pattern in practice:
15481548
```{code-cell} ipython3
15491549
:tags: ["output_scroll"]
1550-
region_lang["maximum"] = region_lang_nums.apply(max, axis=1)
1550+
region_lang["maximum"] = region_lang_nums.max(axis=1)
15511551
region_lang
15521552
```
15531553
You can see above that the `region_lang` data frame now has an additional column named `maximum`.

0 commit comments

Comments
 (0)