我有這個嵌套回圈:
rolling=['10','20']
for i in range(len(ex)):
for d in rolling:
df = nested_df.loc[other_nested_df['pio'][i]:(other_nested_df['pio'][i] 10)].copy()
ex.loc[i]['date_vert_' str(d)=df['date'].iloc[-1]
回圈將不會給任何錯誤,但我不明白為什么在最后資料幀ex沒有其它兩列名為date_vert_10和date_vert_20
uj5u.com熱心網友回復:
更改ex.loc[i][...]為ex.loc[i, ...]:
rolling=['10','20']
for i in range(len(ex)):
for d in rolling:
df = nested_df.loc[other_nested_df['pio'][i]:(other_nested_df['pio'][i] 10)].copy()
ex.loc[i, 'date_vert_' str(d)=df['date'].iloc[-1]
# ^^^^^^^^^^^ changed
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/392776.html
