diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 83a2a509c0743..9fe3c6aa48ca2 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6969,14 +6969,6 @@ def applymap(self, func) -> "DataFrame": -------- DataFrame.apply : Apply a function along input axis of DataFrame. - Notes - ----- - In the current implementation applymap calls `func` twice on the - first column/row to decide whether it can take a fast or slow - code path. This can lead to unexpected behavior if `func` has - side-effects, as they will take effect twice for the first - column/row. - Examples -------- >>> df = pd.DataFrame([[1, 2.12], [3.356, 4.567]]) @@ -6990,8 +6982,9 @@ def applymap(self, func) -> "DataFrame": 0 3 4 1 5 5 - Note that a vectorized version of `func` often exists, which will - be much faster. You could square each number elementwise. + Note that a vectorized version of `func` often exists, + which will be much faster. + You could square each number elementwise. >>> df.applymap(lambda x: x**2) 0 1 @@ -7005,7 +6998,6 @@ def applymap(self, func) -> "DataFrame": 0 1.000000 4.494400 1 11.262736 20.857489 """ - # if we have a dtype == 'M8[ns]', provide boxed values def infer(x): if x.empty: diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 3bb584d4d34e8..b809bc1a1c496 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -9960,7 +9960,7 @@ def _add_numeric_operations(cls): see_also="", examples="", ) - @Appender(_num_doc) + @Appender(_num_doc_mad) def mad(self, axis=None, skipna=None, level=None): if skipna is None: skipna = True @@ -10329,6 +10329,26 @@ def _doc_parms(cls): %(examples)s """ +_num_doc_mad = """ +%(desc)s + +Parameters +---------- +axis : %(axis_descr)s + Axis for the function to be applied on. +skipna : bool, default None + Exclude NA/null values when computing the result. +level : int or level name, default None + If the axis is a MultiIndex (hierarchical), count along a + particular level, collapsing into a %(name1)s. + +Returns +------- +%(name1)s or %(name2)s (if level specified)\ +%(see_also)s\ +%(examples)s +""" + _num_ddof_doc = """ %(desc)s