![](/img/trans.png)
[英]Finding a set of indices that maps the rows of one NumPy ndarray to another
[英]Finding indices of numpy ndarray
我有一個有5個元素的numpy.ndarray(數據),每個元素都有2042行和兩列。 第一列包含日期(以15分鍾為間隔),第二列包含溫度。 我正在編寫一個腳本,它將在24小時內找到最高溫度。 我有一個工作腳本。
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或如何使用另一個索引命令找出何時出現最高溫度?
要在numpy數組中找到最大值的索引,請使用np.argmax()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.