python图片测量_Python-测量中心趋势

python图片测量

python图片测量

Python-测量中心趋势 (Python - Measuring Central Tendency)

Mathematically central tendency means measuring the center or distribution of location of values of a data set. It gives an idea of the average value of the data in the data set and also an indication of how widely the values are spread in the data set. That in turn helps in evaluating the chances of a new input fitting into the existing data set and hence probability of success.

数学上的中心趋势是指测量数据集值的中心或位置分布。 它给出了数据集中数据平均值的概念,并指出了这些值在数据集中分布的范围。 反过来,这有助于评估将新输入拟合到现有数据集中的机会,从而评估成功的可能性。

There are three main measures of central tendency which can be calculated using the methods in pandas python library.

可以使用pandas python库中的方法计算出集中趋势的三种主要度量。

  • Mean - It is the Average value of the data which is a division of sum of the values with the number of values.

    均值-它是数据的平均值,是值的总和除以值的数量。

  • Median - It is the middle value in distribution when the values are arranged in ascending or descending order.

    中位数-当值以升序或降序排列时,它是分布中的中间值。

  • Mode - It is the most commonly occurring value in a distribution.

    模式-它是分布中最常见的值。

计算均值和中位数 (Calculating Mean and Median)

The pandas functions can be directly used to calculate these values.

熊猫函数可以直接用于计算这些值。


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,29,23,34,40,30,51,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 "Mean Values in the Distribution"
print df.mean()
print "*******************************"
print "Median Values in the Distribution"
print df.median()

Its output is as follows −

输出如下-


Mean Values in the Distribution
Age       31.833333
Rating     3.743333
dtype: float64
*******************************
Median Values in the Distribution
Age       29.50
Rating     3.79
dtype: float64

计算模式 (Calculating Mode)

Mode may or may not be available in a distribution depending on whether the data is continous or whether there are values which has maximum frquency. We take a simple distribution below to find out the mode. Here we have a value which has maximum frequency in the distribution.

根据数据是连续的还是有最大频率的值,模式在分发中是否可用。 我们通过下面的简单分布来找出模式。 在这里,我们有一个在分布中具有最大频率的值。


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])}
#Create a DataFrame
df = pd.DataFrame(d)

print df.mode()

Its output is as follows −

输出如下-

chartprop2.png

     Age      Name
0   25.0    Andres
1    NaN  Chanchal
2    NaN    Gasper
3    NaN      Jack
4    NaN     James
5    NaN       Lee
6    NaN    Naviya
7    NaN     Ricky
8    NaN     Smith
9    NaN     Steve
10   NaN       Tom
11   NaN       Vin

翻译自: https://www.tutorialspoint.com/python_data_science/python_measuring_central_tendency.htm

python图片测量

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值