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