eland.groupby.DataFrameGroupBy.var#

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

示例#

>>> df = ed.DataFrame(
...   "http://localhost:9200", "flights",
...   columns=["AvgTicketPrice", "Cancelled", "dayOfWeek", "timestamp", "DestCountry"]
... )
>>> df.groupby("DestCountry").var() 
             AvgTicketPrice  Cancelled  dayOfWeek
DestCountry
AE             75789.979090   0.130443   3.950549
AR             59683.055316   0.125979   3.783429
AT             65726.669676   0.144610   4.090013
AU             65088.483446   0.113094   3.833562
CA             68149.950516   0.116496   3.688139
...                     ...        ...        ...
RU             67305.277617   0.114107   3.852666
SE             53740.570338   0.127062   3.942132
TR             61245.521047   0.094868   4.100420
US             74349.939410   0.109638   3.758700
ZA             62920.072901   0.126608   3.775609

[32 rows x 3 columns]