類似numpy庫,可見此博文 numpy的統計函式
1.0 適用於series和dataframe資料型別
函式名描述sum()
求和mean()
求期望count()
求非nan值的個數
std()
求標準差
var()
求方差max()
最大值min()
最小值median()
中位數2.0 只適用於series型別
方法名描述.argmin() .argmax()
計算資料的最小/大值所在位置的索引位置(自動索引)
.idxmin() .idxmax()
計算資料的最小/大值所在位置的索引位置(自定義索引)
#在series型別當中使用者可以使用自定義索引,而系統也會儲存好自動索引
.describe(
) 針對0軸(各列)的統計彙總
案例**如下:#注意下標真正對應的列i=i+1
>>
>
import pandas as pd
>>
> a=pd.series([9
,8,5
,1],index=
['a'
,'b'
,'c'
,'d'])
>>
> a
a 9
b 8
c 5
d 1
dtype: int64
>>
> a.describe(
)count 4.000000
mean 5.750000
std 3.593976
min1.00000025%
4.00000050%
6.50000075%
8.250000
max9.000000
dtype: float64
>>
>
type
(a.describe())
<
class
'pandas.core.series.series'
>
>>
> a.describe()[
'count'
]4.0
>>
> a.describe()[
'max'
]9.0
#以下為dataframe資料型別
>>
>
import numpy as np
>>
> b=pd.dataframe(np.arange(20)
.reshape(4,
5),index=
['c'
,'v'
,'b'
,'n'])
>>
> b
01234
c 012
34v 567
89b 10
1112
1314
n 15
1617
1819
>>
> b.describe()0
1234
count 4.000000
4.000000
4.000000
4.000000
4.000000
mean 7.500000
8.500000
9.500000
10.500000
11.500000
std 6.454972
6.454972
6.454972
6.454972
6.454972
min0.000000
1.000000
2.000000
3.000000
4.00000025%
3.750000
4.750000
5.750000
6.750000
7.75000050%
7.500000
8.500000
9.500000
10.500000
11.50000075%
11.250000
12.250000
13.250000
14.250000
15.250000
max15.000000
16.000000
17.000000
18.000000
19.000000
>>
> b.describe(
).ix[
'max']0
15.0
116.0
217.0
318.0
419.0
name:
max, dtype: float64
>>
> b.describe()[
2]#對地3列進行統計彙總,
count 4.000000
mean 9.500000
std 6.454972
min2.00000025%
5.75000050%
9.50000075%
13.250000
max17.000000
name:
2, dtype: float64
Pandas庫(2) 資料的統計分析
1.0 pandas 中的資料型別 series dataframe 一維二維的 型 每個元素都有各自的標籤 數字 字元 可儲存多個不同型別資料,每個軸都有標籤 可視為乙個由帶標籤的元素組成的 numpy 陣列 可視為乙個 series 的字典 2.0 適用於series和dataframe資料型別...
pandas的資料累計統計分析
本文的主要內容是基於中國大學mooc 慕課 中的 python資料分析與視覺化 課程進行整理和總結。資料的累計統計分析是能夠對序列中的前n個數進行累計運算,對於一些大量的資料分析中,可以減少for迴圈的使用,也使得資料的運算變得更加靈活。pandas提供了一組資料累計統計分析函式,這些函式都適用於s...
pandas的統計分析
import pandas as pd import numpy as np data pd.read excel meal order detail.xlsx print data n data print data 的列索引 n data.columns print data 的資料型別 n d...