October 2019
Beginner to intermediate
674 pages
16h 43m
English
The map() method is similar to the apply method as it helps in making elementwise changes that have been defined by functions. However, in addition, the map function also accepts a series or dictionary to define these elementwise changes.
Using the map function, let's change some of the values in the "Wins" column:
sample_df["Wins"].map({62 : 60, 38 : 20})
The following is the output:

Values for which the mapping is not defined are replaced with NAs.
Read now
Unlock full access