Python|熊猫 dataframe.kurt()
Python是一种用于进行数据分析的出色语言,主要是因为以数据为中心的Python包的奇妙生态系统。 Pandas就是其中之一,它使导入和分析数据变得更加容易。
Pandas dataframe.kurt()
函数使用 Fisher 的峰度定义(正常峰度 == 0.0)返回请求轴上的无偏峰度。由 N-1 归一化。
Syntax: DataFrame.kurt(axis=None, skipna=None, level=None, numeric_only=None, **kwargs)
Parameters :
axis : {index (0), columns (1)}
skipna : Exclude NA/null values when computing the result
level : If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a Series
numeric_only : Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data. Not implemented for Series.
Returns : kurt : Series or DataFrame (if level specified)
示例 #1:使用kurt()
函数查找索引轴上的峰度。
# importing pandas as pd
import pandas as pd
# Creating the dataframe
df = pd.DataFrame({"A":[12, 4, 5, 44, 1],
"B":[5, 2, 54, 3, 2],
"C":[20, 16, 7, 3, 8],
"D":[14, 3, 17, 2, 6]})
# Print the dataframe
df
让我们使用dataframe.kurt()
函数来查找峰度。
# find the kurtosis over the index axis
df.kurt(axis = 0)
输出 :
示例 #2:使用kurt()
函数查找其中包含一些Na
值的数据帧的峰度。查找索引轴上的峰度。
# importing pandas as pd
import pandas as pd
# Creating the dataframe
df = pd.DataFrame({"A":[12, 4, 5, None, 1],
"B":[7, 2, 54, 3, None],
"C":[20, 16, 11, 3, 8],
"D":[14, 3, None, 2, 6]})
# to find the kurtosis
# skip the Na values when finding the kurtosis
df.kurt(axis = 0, skipna = True)
输出 :