pyspark.pandas.groupby.GroupBy.mad

GroupBy.mad() → FrameLike[source]

Compute mean absolute deviation of groups, excluding missing values.

New in version 3.4.0.

Deprecated since version 3.4.0.

Examples

>>> df = ps.DataFrame({"A": [1, 2, 1, 1], "B": [True, False, False, True],
...                    "C": [3, 4, 3, 4], "D": ["a", "b", "b", "a"]})
>>> df.groupby("A").mad()
          B         C
A
1  0.444444  0.444444
2  0.000000  0.000000
>>> df.B.groupby(df.A).mad()
A
1    0.444444
2    0.000000
Name: B, dtype: float64