eland.DataFrame.mode#
- DataFrame.mode(numeric_only: bool = False, dropna: bool = True, es_size: int = 10) DataFrame #
计算 DataFrame 的众数
参数#
- numeric_only: {True, False} 默认值为 False
要返回的哪种数据类型 - True: 返回所有数字或时间戳列 - False: 返回所有列
- dropna: {True, False} 默认值为 True
True: 不考虑 NaN/NaT 的计数。
False: 考虑 NaN/NaT 的计数。
- es_size: 默认值为 10
如果众数有多个值,要返回的行数
另请参见#
示例#
>>> ed_ecommerce = ed.DataFrame('http://localhost:9200', 'ecommerce') >>> ed_df = ed_ecommerce.filter(["total_quantity", "geoip.city_name", "customer_birth_date", "day_of_week", "taxful_total_price"]) >>> ed_df.mode(numeric_only=False) total_quantity geoip.city_name customer_birth_date day_of_week taxful_total_price 0 2 New York NaT Thursday 53.98
>>> ed_df.mode(numeric_only=True) total_quantity taxful_total_price 0 2 53.98
>>> ed_df = ed_ecommerce.filter(["products.tax_amount","order_date"]) >>> ed_df.mode() products.tax_amount order_date 0 0.0 2016-12-02 20:36:58 1 NaN 2016-12-04 23:44:10 2 NaN 2016-12-08 06:21:36 3 NaN 2016-12-08 09:38:53 4 NaN 2016-12-12 11:38:24 5 NaN 2016-12-12 19:46:34 6 NaN 2016-12-14 18:00:00 7 NaN 2016-12-15 11:38:24 8 NaN 2016-12-22 19:39:22 9 NaN 2016-12-24 06:21:36
>>> ed_df.mode(es_size = 3) products.tax_amount order_date 0 0.0 2016-12-02 20:36:58 1 NaN 2016-12-04 23:44:10 2 NaN 2016-12-08 06:21:36