[英]Computing mean, median and mode in python
How to calculate central tendency (Median and mode) on pandas columns with Python 3, if the data has given with attribute Jumlah_individu
?如果数据具有Jumlah_individu
属性, Jumlah_individu
使用 Python 3 Jumlah_individu
列的集中趋势(中值和Jumlah_individu
?
You can use .median()
to get the middle value in a list.您可以使用.median()
获取列表中的中间值。
ex.前任。 df['Jumlah_individu'].median()
You can use .mode()
to get the highest frequency value in a list.您可以使用.mode()
获取列表中的最高频率值。
ex.前任。 df['Jumlah_individu'].mode()[0]
where [0]
to get the highest frequency value. df['Jumlah_individu'].mode()[0]
where [0]
获取最高频率值。
只需尝试data.describe()
即可获得如图所示的列表
You can create a dictionary for the mean, median and mode您可以为均值、中值和众数创建字典
CentralTendacy = {}
CentralTendacy['Mean'] = df['Jumlah_individu'].mean()
CentralTendacy['Median'] = df['Jumlah_individu'].median()
CentralTendacy['Mode'] = df['Jumlah_individu'].mode()[0]
CentralTendacy
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.