Skip to content

Commit 211ecd5

Browse files
manuelsjreback
authored andcommitted
Make Series.map() documentation a bit more verbose
Author: manuels <[email protected]> Closes pandas-dev#15235 from manuels/patch-1 and squashes the following commits: c5113f2 [manuels] Make Series.map() documentation a bit more verbose
1 parent cd67704 commit 211ecd5

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

pandas/core/series.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -2089,13 +2089,15 @@ def map(self, arg, na_action=None):
20892089
Examples
20902090
--------
20912091
2092-
Map inputs to outputs
2092+
Map inputs to outputs (both of type `Series`)
20932093
2094+
>>> x = pd.Series([1,2,3], index=['one', 'two', 'three'])
20942095
>>> x
20952096
one 1
20962097
two 2
20972098
three 3
20982099
2100+
>>> y = pd.Series(['foo', 'bar', 'baz'], index=[1,2,3])
20992101
>>> y
21002102
1 foo
21012103
2 bar
@@ -2106,6 +2108,16 @@ def map(self, arg, na_action=None):
21062108
two bar
21072109
three baz
21082110
2111+
Mapping a dictionary keys on the index labels works similar as
2112+
with a `Series`:
2113+
2114+
>>> z = {1: 'A', 2: 'B', 3: 'C'}
2115+
2116+
>>> x.map(z)
2117+
one A
2118+
two B
2119+
three C
2120+
21092121
Use na_action to control whether NA values are affected by the mapping
21102122
function.
21112123
@@ -2127,6 +2139,11 @@ def map(self, arg, na_action=None):
21272139
3 NaN
21282140
dtype: object
21292141
2142+
See Also
2143+
--------
2144+
Series.apply: For applying more complex functions on a Series
2145+
DataFrame.apply: Apply a function row-/column-wise
2146+
DataFrame.applymap: Apply a function elementwise on a whole DataFrame
21302147
"""
21312148

21322149
if is_extension_type(self.dtype):

0 commit comments

Comments
 (0)