@@ -9827,7 +9827,7 @@ def map(
9827
9827
9828
9828
>>> df_copy = df.copy()
9829
9829
>>> df_copy.iloc[0, 0] = pd.NA
9830
- >>> df_copy.applymap (lambda x: len(str(x)), na_action='ignore')
9830
+ >>> df_copy.map (lambda x: len(str(x)), na_action='ignore')
9831
9831
0 1
9832
9832
0 NaN 4
9833
9833
1 5.0 5
@@ -9840,7 +9840,7 @@ def map(
9840
9840
0 1.000000 4.494400
9841
9841
1 11.262736 20.857489
9842
9842
9843
- But it's better to avoid applymap in that case.
9843
+ But it's better to avoid map in that case.
9844
9844
9845
9845
>>> df ** 2
9846
9846
0 1
@@ -9860,7 +9860,7 @@ def map(
9860
9860
def infer (x ):
9861
9861
return x ._map_values (func , na_action = na_action )
9862
9862
9863
- return self .apply (infer ).__finalize__ (self , "applymap " )
9863
+ return self .apply (infer ).__finalize__ (self , "map " )
9864
9864
9865
9865
def applymap (
9866
9866
self , func : PythonFuncType , na_action : str | None = None , ** kwargs
@@ -9895,6 +9895,19 @@ def applymap(
9895
9895
DataFrame.apply : Apply a function along input axis of DataFrame.
9896
9896
DataFrame.map : Apply a function along input axis of DataFrame.
9897
9897
DataFrame.replace: Replace values given in `to_replace` with `value`.
9898
+
9899
+ Examples
9900
+ --------
9901
+ >>> df = pd.DataFrame([[1, 2.12], [3.356, 4.567]])
9902
+ >>> df
9903
+ 0 1
9904
+ 0 1.000 2.120
9905
+ 1 3.356 4.567
9906
+
9907
+ >>> df.map(lambda x: len(str(x)))
9908
+ 0 1
9909
+ 0 3 4
9910
+ 1 5 5
9898
9911
"""
9899
9912
warnings .warn (
9900
9913
"DataFrame.applymap has been deprecated. Use DataFrame.map instead." ,
0 commit comments