@@ -9854,7 +9854,7 @@ def map(
9854
9854
9855
9855
>>> df_copy = df.copy()
9856
9856
>>> df_copy.iloc[0, 0] = pd.NA
9857
- >>> df_copy.applymap (lambda x: len(str(x)), na_action='ignore')
9857
+ >>> df_copy.map (lambda x: len(str(x)), na_action='ignore')
9858
9858
0 1
9859
9859
0 NaN 4
9860
9860
1 5.0 5
@@ -9867,7 +9867,7 @@ def map(
9867
9867
0 1.000000 4.494400
9868
9868
1 11.262736 20.857489
9869
9869
9870
- But it's better to avoid applymap in that case.
9870
+ But it's better to avoid map in that case.
9871
9871
9872
9872
>>> df ** 2
9873
9873
0 1
@@ -9887,7 +9887,7 @@ def map(
9887
9887
def infer (x ):
9888
9888
return x ._map_values (func , na_action = na_action )
9889
9889
9890
- return self .apply (infer ).__finalize__ (self , "applymap " )
9890
+ return self .apply (infer ).__finalize__ (self , "map " )
9891
9891
9892
9892
def applymap (
9893
9893
self , func : PythonFuncType , na_action : str | None = None , ** kwargs
@@ -9922,6 +9922,19 @@ def applymap(
9922
9922
DataFrame.apply : Apply a function along input axis of DataFrame.
9923
9923
DataFrame.map : Apply a function along input axis of DataFrame.
9924
9924
DataFrame.replace: Replace values given in `to_replace` with `value`.
9925
+
9926
+ Examples
9927
+ --------
9928
+ >>> df = pd.DataFrame([[1, 2.12], [3.356, 4.567]])
9929
+ >>> df
9930
+ 0 1
9931
+ 0 1.000 2.120
9932
+ 1 3.356 4.567
9933
+
9934
+ >>> df.map(lambda x: len(str(x)))
9935
+ 0 1
9936
+ 0 3 4
9937
+ 1 5 5
9925
9938
"""
9926
9939
warnings .warn (
9927
9940
"DataFrame.applymap has been deprecated. Use DataFrame.map instead." ,
0 commit comments