我有以下数组:
start prgrm_x64.exe > inputtext
start prgrm_x64.exe < inputtext
start prgrm_x64.exe | inputtext
如何获取以下列表?
arr = [ nan nan nan 1.600e-01 1.000e+00 1.600e-01 9.999e-01 1.000e-04 1.600e-01 1.010e-01 nan 1.600e-01]
谢谢
答案 0 :(得分:3)
使用numpy split
根据条件拆分数组。只要np.diff(np.isnan(arr))
== True
np.split(arr, np.where(np.diff(np.isnan(arr))== True)[0]+1)
[array([nan, nan, nan]),
array([1.600e-01, 1.000e+00, 1.600e-01, 9.999e-01, 1.000e-04, 1.600e-01,
1.010e-01]),
array([nan]),
array([0.16])]