int8 |
8 位元有號整數 |
int16 |
16 位元有號整數 |
int32 |
32 位元有號整數 |
int64 |
64 位元有號整數 |
uint8 |
8 位元無號整數 |
uint16 |
16 位元無號整數 |
uint32 |
32 位元無號整數 |
uint64 |
64 位元無號整數 |
float16 |
16 位元浮點數 |
float32 |
32 位元浮點數 |
import numpy as np
x=np.array([1,2,3],dtype=np.int16)
print(x,type(x))
print(x[0],type(x[0]))


import numpy as np
def myfun(a:np.ndarray):
return sum(a)
lst = [1,2,3]
ary = np.array(lst)
print(“list: %r, Type: %r”%(lst,type(lst)) )
print(“Array: %r, Type: %r” %( ary ,type(ary)))
print(“Summation:”,myfun(ary) )
lst2D = [
[1,2,3],
[4,5,6]
]
ary2D = np.array(lst2D)
print(ary2D)
print( “Type of 2D array:”,type(ary2D) )
#一樣是numpy.ndarray,沒有顯示維度

![Python: pandas.DataFrame()處理雙維度資料,dict跟2D list轉為DataFrame有何差別?如何用index及columns屬性客製化index跟欄位名稱?df.index = [“一”,”二”,”三”,”四”] ; df.columns = 使用.head(n) ; .tail(m) ;取首n列,尾m列; .at[index,欄位名稱] 取單一資料 ; .iat[index,欄位順序] 取單一資料 ; .loc[index,欄位名稱] 取資料 ; .iloc[index,欄位順序];df.iloc[ [0,1],[0,2]])取資料 ; df.iloc[ 0:3,0:2]切片 Python: pandas.DataFrame()處理雙維度資料,dict跟2D list轉為DataFrame有何差別?如何用index及columns屬性客製化index跟欄位名稱?df.index = [“一”,”二”,”三”,”四”] ; df.columns = 使用.head(n) ; .tail(m) ;取首n列,尾m列; .at[index,欄位名稱] 取單一資料 ; .iat[index,欄位順序] 取單一資料 ; .loc[index,欄位名稱] 取資料 ; .iloc[index,欄位順序];df.iloc[ [0,1],[0,2]])取資料 ; df.iloc[ 0:3,0:2]切片](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2022/11/20221111093547_79.png?quality=90&zoom=2&ssl=1&resize=350%2C233)









近期留言