0
這是一個非常愚蠢的問題,但我無法做出解決方案。我的問題是,當我的代碼達到最後的價值時,我得到一個錯誤。最後一個值的循環錯誤
Error: 41800 (last value of loop)
我的代碼:
for x in (motorwayframe.index):
if((motorwayframe['machine_id'][x]) != (motorwayframe['machine_id'][x+1])):
motorwayframe['distance'] = np.nan
else:
pass
那麼,如果x是最後一個索引,顯然x + 1會給索引錯誤,不是嗎? –