Skip to content

Commit 0d2808b

Browse files
authored
Add more documentation to Series.map()
1 parent 25abfe1 commit 0d2808b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pandas/core/series.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -2121,13 +2121,17 @@ def map(self, arg, na_action=None):
21212121
Examples
21222122
--------
21232123
2124-
Map inputs to outputs
2124+
>>> import pandas as pd
2125+
2126+
Map inputs to outputs (both of type `Series`)
21252127
2128+
>>> x = pd.Series([1,2,3], index=['one', 'two', 'three'])
21262129
>>> x
21272130
one 1
21282131
two 2
21292132
three 3
21302133
2134+
>>> y = pd.Series(['foo', 'bar', 'baz'], index=[1,2,3])
21312135
>>> y
21322136
1 foo
21332137
2 bar
@@ -2138,8 +2142,9 @@ def map(self, arg, na_action=None):
21382142
two bar
21392143
three baz
21402144
2141-
>>> z
2142-
{1: 'A', 2: 'B', 3: 'C'}
2145+
Mapping a dictionary keys on the index labels works similar as with a `Series`:
2146+
2147+
>>> z = {1: 'A', 2: 'B', 3: 'C'}
21432148
21442149
>>> x.map(z)
21452150
one A

0 commit comments

Comments
 (0)