簡體   English   中英

如何從python中的int64創建標量索引?

[英]How to create a scalar index out of a int64 in python?

我有這個代碼:

valueXs = [7, 9, 10, 11, 8, 5, 2, 9, 18, 17, 15, 7]
diff = np.diff(np.sign(np.diff(valueXs)))
maxi = np.where(diff < 0)[0]+1

但是當我嘗試: valueXs[maxi]我得到錯誤:

TypeError: only integer scalar arrays can be converted to a scalar index
valueXs = np.array([7, 9, 10, 11, 8, 5, 2, 9, 18, 17, 15, 7])
diff = np.diff(np.sign(np.diff(valueXs)))
maxi = np.where(diff < 0)[0]+1
valueXs[maxi]

將您的 valueXs 轉換為 np.array 以允許數組索引

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM