python图片测量
Python-测量方差 (Python - Measuring Variance)
In statistics, variance is a measure of how far a value in a data set lies from the mean value. In other words, it indicates how dispersed the values are. It is measured by using standard deviation. The other method commonly used is skewness.
在统计数据中,方差是数据集中某个值与平均值之间的距离的量度。 换句话说,它指示值的分散程度。 通过使用标准偏差进行测量。 常用的另一种方法是偏度。
Both of these are calculated by using functions available in pandas library.
这两个都是通过使用pandas库中可用的函数来计算的。
测量标准偏差 (Measuring Standard Deviation)
Standard deviation is square root of variance. variance is the average of squared difference of values in a data set from the mean value. In python we calculate this value by using the function std() from pandas library.
标准偏差是方差的平方根。 方差是数据集中值与平均值的平方差的平均值。 在python中,我们通过使用pandas库中的函数std()计算此值。
import pandas as pd
#Create a Dictionary of series
d = {'Name':pd.Series(['Tom','James','Ricky','Vin','Steve','Smith','Jack',
'Lee','Chanchal','Gasper','Naviya','Andres']),
'Age':pd.Series([25,26,25,23,30,25,23,34,40,30,25,46]),
'Rating':pd.Series([4.23,3.24,3.98,2.56,3.20,4.6,3.8,3.78,2.98,4.80,4.10,3.65])}
#Create a DataFrame
df = pd.DataFrame(d)
# Calculate the standard deviation
print df.std()
Its output is as follows −
其输出如下-
Age 7.265527
Rating 0.661628
dtype: float64
测量偏度 (Measuring Skewness)
It used to determine whether the data is symmetric or skewed. If the index is between -1 and 1, then the distribution is symmetric. If the index is no more than -1 then it is skewed to the left and if it is at least 1, then it is skewed to the right
它用于确定数据是对称的还是偏斜的。 如果索引在-1和1之间,则分布是对称的。 如果索引不大于-1,则向左倾斜,如果索引至少为1,则向右倾斜
import pandas as pd
#Create a Dictionary of series
d = {'Name':pd.Series(['Tom','James','Ricky','Vin','Steve','Smith','Jack',
'Lee','Chanchal','Gasper','Naviya','Andres']),
'Age':pd.Series([25,26,25,23,30,25,23,34,40,30,25,46]),
'Rating':pd.Series([4.23,3.24,3.98,2.56,3.20,4.6,3.8,3.78,2.98,4.80,4.10,3.65])}
#Create a DataFrame
df = pd.DataFrame(d)
print df.skew()
Its output is as follows −
其输出如下-
Age 1.443490
Rating -0.153629
dtype: float64
So the distribution of age rating is symmetric while the distribution of age is skewed to the right.
因此,年龄等级的分布是对称的,而年龄分布则偏向右侧。
翻译自: https://www.tutorialspoint.com/python_data_science/python_measuring_variance.htm
python图片测量
本文介绍了在Python中如何使用pandas库计算数据集的方差和标准偏差,方差是衡量数值与平均值偏离程度的指标,而标准偏差是方差的平方根。此外,还探讨了通过计算偏度判断数据是否对称的方法。

645

被折叠的 条评论
为什么被折叠?



