📜  Python|熊猫 dataframe.sem()

📅  最后修改于: 2022-05-13 01:54:40.538000             🧑  作者: Mango

Python|熊猫 dataframe.sem()

Python是一种用于进行数据分析的出色语言,主要是因为以数据为中心的Python包的奇妙生态系统。 Pandas就是其中之一,它使导入和分析数据变得更加容易。

Pandas dataframe.sem()函数返回请求轴上平均值的无偏标准误差。统计量的标准误差 (SE)(通常是参数的估计值)是其抽样分布的标准偏差 [1] 或该标准偏差的估计值。如果参数或统计量是平均值,则称为平均值的标准误差(SEM)。

有关代码中使用的 CSV 文件的链接,请单击此处

示例 #1:使用sem()函数查找给定数据帧在索引轴上的平均值的标准误差。

# importing pandas as pd
import pandas as pd
  
# Creating the dataframe 
df = pd.read_csv("nba.csv")
  
# Print the dataframe
df

让我们使用dataframe.sem()函数来查找索引轴上平均值的标准误差。

# find standard error of the mean of all the columns
df.sem(axis = 0)

输出 :

请注意,所有非数字列和值都不会自动包含在数据框的计算中。我们不必专门输入数字列来计算平均值的标准误差。示例 #2:使用sem()函数查找列轴上平均值的标准误差。也不要在数据帧的计算中跳过NaN值。

# importing pandas as pd
import pandas as pd
  
# Creating the dataframe 
df = pd.read_csv("nba.csv")
  
# Calculate the standard error of 
# the mean of all the rows in dataframe
df.sem(axis = 1, skipna = False)

输出 :

当我们包含NaN值时,它将导致该特定行或列成为NaN