python求均值、中位數、衆數的方法

首先須要數據源,這裏隨便寫了一個:python nums = [1,2,3,4] 求均值和中位數都可以使用numpy庫的方法: import numpy as np #均值 np.mean(nums) #中位數 np.median(nums) 求衆數方法一: 在numpy中沒有直接的方法,可是也能夠這樣實現: import numpy as np counts = np.bincount(nu
相關文章
相關標籤/搜索