eland.groupby.DataFrameGroupBy.mean#

DataFrameGroupBy.mean(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.mean

示例#

>>> df = ed.DataFrame(
...   "http://localhost:9200", "flights",
...   columns=["AvgTicketPrice", "Cancelled", "dayOfWeek", "timestamp", "DestCountry"]
... )
>>> df.groupby("DestCountry").mean(numeric_only=False) 
             AvgTicketPrice  Cancelled  dayOfWeek                     timestamp
DestCountry
AE               605.132970   0.152174   2.695652 2018-01-21 16:58:07.891304443
AR               674.827252   0.147541   2.744262 2018-01-21 22:18:06.593442627
AT               646.650530   0.175066   2.872679 2018-01-21 15:54:42.469496094
AU               669.558832   0.129808   2.843750 2018-01-22 02:28:39.199519287
CA               648.747109   0.134534   2.951271 2018-01-22 14:40:47.165254150
...                     ...        ...        ...                           ...
RU               662.994963   0.131258   2.832206 2018-01-21 07:11:16.534506104
SE               660.612988   0.149020   2.682353 2018-01-22 07:48:23.447058838
TR               485.253247   0.100000   1.900000 2018-01-16 16:02:33.000000000
US               595.774391   0.125315   2.753900 2018-01-21 16:55:04.456970215
ZA               643.053057   0.148410   2.766784 2018-01-22 15:17:56.141342773

[32 rows x 4 columns]