pandas常用的資料統計函式總結。
df = pd.dataframe()
結果如下:
a b c
0 3 1.2 aa
1 4 2.4 bb
2 8 4.5 cc
3 9 7.3 dd
df.describe() # 檢視資料值列的匯**計, 字串型別的列不會顯示
結果如下:
a b
count 4.00000 4.000000
mean 6.00000 3.850000
std 2.94392 2.673948
min 3.00000 1.200000
25% 3.75000 2.100000
50% 6.00000 3.450000
75% 8.25000 5.200000
max 9.00000 7.300000
df.mean() # 檢視數值列的平均值,字串型別的列不會統計
結果如下:
a 6.00
b 3.85
dtype: float64
df.corr() # 返回數值列之間的相關係數
結果如下:
a b
a 1.000000 0.952757
b 0.952757 1.000000
df.count() # 返回每一列中的非空值的個數
結果如下:
a 4
b 4
c 4
dtype: int64
df.max() # 返回每一列的最大值
結果如下:
a 9
b 7.3
c dd
dtype: object
df.min() # 返回每一列的最小值
結果如下:
a 3
b 1.2
c aa
dtype: object
df.median() # 返回每一列的中位數
結果如下:
a 6.00
b 3.45
dtype: float64
df.std() # 返回每一數值列的標準差
結果如下:
a 2.943920
b 2.673948
dtype: float64
df.sum() # 返回每一列的總和
結果如下:
a 24
b 15.4
c aabbccdd
dtype: object
df.isnull().sum() # 統計每列空值的數量
結果如下:
歡迎關注,一起學習
參考:
Python 資料統計入門
linux pip install u pip windows python m pip install u pip anaconda安裝 建立和啟動 conda create name py27 python 2.7 activate py27 列出安裝 conda list 安裝package ...
常用的資料統計Sql 總結
1.統計各個條件下的資料 select batchid,sum cardsum 總金額,sum case when status 1 then cardsum else 0 end as 已使用,sum case when status 2 then cardsum else 0 end as 已凍...
常用的資料統計Sql 總結
最近剛在搞乙個bi的專案,裡面需要大量的sql 資料統計相關運用,加深了我又對sql的理解與使用。所以,分享幾個資料統計時常用的sql 語句總結 1.統計各個條件下的資料 select batchid,sum cardsum 總金額,sum case when status 1 then cards...