DataFrame.kurt(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs) [source]
使用Fisher的峰度定义(正常的峰度== 0.0)在请求的轴上返回无偏峰度。由N-1归一化。
参数: | axis : 要应用的功能的轴。 skipna : 计算结果时排除 level : 整数或级别名称,默认为 如果轴是MultiIndex(分层),则沿特定级别计数, 并折叠为Series。 numeric_only : 布尔值,默认值None 仅包括 如果为None,将尝试使用所有内容, 然后仅使用数字数据。未针对Series实施。 **kwargs 要传递给函数的其他关键字参数。 |
返回值: | Series 或 DataFrame(如果指定级别) |
例子
使用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
print("DataFrame:")
print(df)
# Calculate the kurtosis for each column
kurt_values = df.kurt()
print("\nKurtosis of each column:")
print(kurt_values)
使用该dataframe.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
print("DataFrame:")
print(df)
# Calculate the kurtosis for each column
kurt_values = df.kurt(axis = 0)
print(kurt_values)
输出:
# 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]
})
# Print the dataframe
print("DataFrame:")
print(df)
# Calculate the kurtosis, skipping NaN values
kurt_values = df.kurt(axis=0, skipna=True)
print("\nKurtosis of each column (with NaN values skipped):")
print(kurt_values)
输出: