Skip to content

Commit f322d9e

Browse files
committed
updated map method
1 parent 11392d7 commit f322d9e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

doc/source/user_guide/user_defined_functions.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,18 @@ or Dataframe. It is particularly useful for substituting values or transforming
223223
.. ipython:: python
224224
225225
# Sample DataFrame
226-
s = pd.Series(['cat', 'dog', 'bird'])
226+
df = pd.DataFrame({ 'A': ['cat', 'dog', 'bird'], 'B': ['pig', 'cow', 'lamb'] })
227227
228228
# Using map with a user-defined function
229229
def animal_to_length(animal):
230230
return len(animal)
231231
232-
s_mapped = s.map(animal_to_length)
233-
print(s_mapped)
232+
df_mapped = df.map(animal_to_length)
233+
print(df_mapped)
234234
235235
# This works with lambda functions too
236-
s_lambda = s.map(lambda x: x.upper())
237-
print(s_lambda)
236+
df_lambda = df.map(lambda x: x.upper())
237+
print(df_lambda)
238238
239239
:meth:`DataFrame.pipe`
240240
----------------------

0 commit comments

Comments
 (0)