DataFrame.describe
DataFrame.describe(percentiles=None, include=None, exclude=None, datetime_is_numeric=False)
产生描述性统计。
对于数值数据,结果将包括:计数、平均值、标准值、最小值、最大值、25%、50%和75%;
对于对象数据,结果将包括:count、unique、top、freq和top
Parameters
percentiles | 要包含在输出中的百分比。所有值都应该在0和1之间。默认为:0.25,0.5,0.75 |
---|---|
include | 要包含在结果中的数据类型列表 |
exclude | 要从结果中省略的数据类型列表 |
datetime_is_numeric | 是否将datetime dtypes视为数据 |
Example
import pandas as pd
df = pd.DataFrame({'site':['google', 'baidu', 'wiki', 'pandas'],
'age':[18, 39, 22, 45],
'price': [1.0, 2.0, 3.0, 4.0]})
df.describe()
-----------------------------------------------
age price
count 4.000000 4.000000
mean 31.000000 2.500000
std 13.038405 1.290994
min 18.000000 1.000000
25% 21.000000 1.750000
50% 30.500000 2.500000
75% 40.500000 3.250000
max 45.000000 4.000000
Example
import pandas as pd
df = pd.DataFrame({'site':['google', 'baidu', 'wiki', 'pandas'],
'age':[18, 39, 22, 45],
'price': [1.0, 2.0, 3.0, 4.0]})
df.describe(include=[object])
------------------------------------
site
count 4
unique 4
top baidu
freq 1