Python Pandas dataframe.sem()

Python Pandas dataframe.sem()

Python是一种进行数据分析的伟大语言,主要是因为以数据为中心的Python包的奇妙生态系统。Pandas就是这些包中的一个,它使导入和分析数据变得更加容易。

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

语法 : DataFrame.sem(axis=None, skipna=None, level=None, ddof=1, numeric_only=None, **kwargs)

参数 :
axis: {指数(0),列(1)}。
skipna : 排除NA/null值。如果整个行/列是NA,结果将是NA。
level : 如果坐标axis是一个多指标(分层的),沿着一个特定的层次计数,折叠成一个系列。
ddof :德尔塔自由度。计算中使用的除数是N – ddof,其中N代表元素的数量。
numeric_only :只包括浮动、int、boolean列。如果没有,将尝试使用所有数据,然后只使用数字数据。不实现系列

返回: sem:系列或数据框架(如果指定级别)。

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

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

Python Pandas dataframe.sem()

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

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

输出 :
Python Pandas dataframe.sem()
注意,所有非数字列和数值都自动不包括在数据框架的计算中。我们不必为计算平均值的标准误差而专门输入数字列。

例子#2:使用sem()函数来查找列axis上的平均值的标准误差。同时在计算数据帧时不要跳过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)
Python

输出 :
Python Pandas dataframe.sem()
当我们包括NaN值时,它将导致该特定行或列为NaN。

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

登录

注册