eland.groupby.DataFrameGroupBy.mad#

DataFrameGroupBy.mad(numeric_only: bool = True) pd.DataFrame#

计算每个组的平均绝对偏差值。

参数#

numeric_only: {True, False, None} 默认值为 True

要返回的哪种数据类型 - True: 将所有值返回为 float64,NaN/NaT 值将被移除 - None: 尽可能将所有值返回为相同的数据类型,NaN/NaT 将被移除 - False: 尽可能将所有值返回为相同的数据类型,NaN/NaT 将被保留

返回#

pandas.DataFrame

每个组的每个数值列的平均绝对偏差值

另请参见#

pandas.core.groupby.GroupBy.mad

示例#

>>> df = ed.DataFrame(
...   "http://localhost:9200", "flights",
...   columns=["AvgTicketPrice", "Cancelled", "dayOfWeek", "timestamp", "DestCountry"]
... )
>>> df.groupby("DestCountry").mad() 
             AvgTicketPrice  Cancelled  dayOfWeek
DestCountry
AE               233.697174        NaN        1.5
AR               189.250061        NaN        2.0
AT               195.823669        NaN        2.0
AU               202.539764        NaN        2.0
CA               203.344696        NaN        2.0
...                     ...        ...        ...
RU               206.431702        NaN        2.0
SE               178.658447        NaN        2.0
TR               221.863434        NaN        1.0
US               228.461365        NaN        2.0
ZA               192.162842        NaN        2.0

[32 rows x 3 columns]