Reputation: 21
How to calculate central tendency (Median and mode) on pandas columns with Python 3, if the data has given with attribute Jumlah_individu
?
Upvotes: 0
Views: 14479
Reputation: 455
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
Upvotes: 0
Reputation: 105
Simply try data.describe()
and you can get that list as shown in the pic
Upvotes: 5
Reputation: 2048
You can use .median()
to get the middle value in a list.
ex. df['Jumlah_individu'].median()
You can use .mode()
to get the highest frequency value in a list.
ex. df['Jumlah_individu'].mode()[0]
where [0]
to get the highest frequency value.
Upvotes: 7