From 83ce0286366e41e5c5deb7e800c10876228fd444 Mon Sep 17 00:00:00 2001 From: Muralidharan Date: Wed, 29 Apr 2026 18:53:40 +0530 Subject: [PATCH] DOC: improve Series.map examples --- pandas/core/series.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandas/core/series.py b/pandas/core/series.py index 28827a014b244..fd89fe3ffec29 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4776,6 +4776,15 @@ def map( 3 rabbit dtype: str + `map` can also be used for element-wise transformations with functions: + + >>> ser = pd.Series([1, 2, 3]) + >>> ser.map(lambda x: x + 1) + 0 2 + 1 3 + 2 4 + dtype: int64 + ``map`` accepts a ``dict`` or a ``Series``. Values that are not found in the ``dict`` are converted to ``NaN``, unless the dict has a default value (e.g. ``defaultdict``):