0
我有一個numpy.ndarray(數據)有5個元素,每個元素有2042行和兩列。第一列包含日期(間隔15分鐘),第二列包含溫度。我正在製作一個腳本,可以在24小時內找到最高溫度。我有一個工作腳本。numpy ndarray的查找索引
x1=0
y1=95
maxTblue=[]
for i in range(int(len(data[0])/96)+1):
#collect the max temp for 24-hr period
maxTblue.append(max(data[0][x1:y1,1]))
#add 96 to shift to the next 24-hr period
x1+=96
y1+=96
現在,我希望能夠收集每個24小時內發生最高溫度的日期。我嘗試了下面的腳本,但它給了我錯誤的日期。日期應該增加24小時,但當前腳本從第一個24小時內返回日期。
maxdateBlue=[]
locblue=[]
x3=0
y3=95
for i in range(int(len(data[0])/96)+1):
#index for the max temp
locblue.append(np.where(data[0][x3:y3,1]==maxTblue[i]))
#date where the max temp occurs
maxdateBlue.append(data[0][locblue[i],0])
x3+=96
y3+=96
如何正確使用np.where,或者我如何使用其他指數命令,以查找出來的時候我的最大溫度下發生?