模組安裝步驟 check List#
測試資料分析的相關套件、依賴是否有成功安裝
## import numpy and pandas
import numpy as np
import pandas as pd
## numpy and pandas version check
print('軟體版本確認 Package version check !')
print('Numpy with version: ', np.__version__)
print('Pandas with version: ', pd.__version__)
軟體版本確認 Package version check !
Numpy with version: 1.24.4
Pandas with version: 2.0.3
套件的小小範例:#
套件使用的小範例,用於證明軟體安裝成功
Numpy 基本範例:#
說明可以看 Numpy官網
建立一個基本陣列
# create array with integer type
array1 = np.arange(4,14, dtype=np.int64)
print ("print 1st array: ",array1)
# create array with float type
array2 = np.arange(-4,4,0.5,dtype=np.float64)
print("print 2nd array: ", array2)
# create matrixs from an array
print('reshape 1st array to 2X5 matrix: ', array1.reshape(2,5))
print('reshape 1st array to 5X2 matrix: ', array1.reshape(5,2))
print ("print 1st array Again: ",array1)
print 1st array: [ 4 5 6 7 8 9 10 11 12 13]
print 2nd array: [-4. -3.5 -3. -2.5 -2. -1.5 -1. -0.5 0. 0.5 1. 1.5 2. 2.5
3. 3.5]
reshape 1st array to 2X5 matrix: [[ 4 5 6 7 8]
[ 9 10 11 12 13]]
reshape 1st array to 5X2 matrix: [[ 4 5]
[ 6 7]
[ 8 9]
[10 11]
[12 13]]
print 1st array Again: [ 4 5 6 7 8 9 10 11 12 13]
Pandas 基本範例:#
使用 Pandas 建立 Series 資料
# create a series with indexs through pandas
series1 = pd.Series(np.arange(0,10))
print(series1)
series2 = pd.Series(np.arange(0,5),index=['a','b','c','d','e'])
print(series2)
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
dtype: int64
a 0
b 1
c 2
d 3
e 4
dtype: int64
如果上述測試都成功代表,軟體已安裝成功