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.Series.nsmallest() 找到n個與target差距最小的index?再從中找到距離idxmax最近的index?避免誤抓sidelobes的index? targetIdx = (serMean-target_value).abs().nsmallest(n).index.tolist() ;Series切片: .loc[標籤名1:標籤名2] (會含標籤名2) ; .iloc[位置1:位置2] (不含位置2) Python 如何用pandas.Series.nsmallest() 找到n個與target差距最小的index?再從中找到距離idxmax最近的index?避免誤抓sidelobes的index? targetIdx = (serMean-target_value).abs().nsmallest(n).index.tolist() ;Series切片: .loc[標籤名1:標籤名2] (會含標籤名2) ; .iloc[位置1:位置2] (不含位置2)](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2023/02/20230222082954_53.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



![Python: 如何用numpy.ndarray的reshape 將3D array轉為2D array,再轉為pandas.DataFrame? arr.reshape( arr.shape[0] * arr.shape[1] , -1) Python: 如何用numpy.ndarray的reshape 將3D array轉為2D array,再轉為pandas.DataFrame? arr.reshape( arr.shape[0] * arr.shape[1] , -1)](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2023/03/20230320082325_85.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

近期留言