我正在使用熊貓來排序通過Excel電子表格。我想執行一個if/elif函數來在我的數據框內的新列中返回一個字符串。我試圖返回一個名爲「action」的新列,它返回基於時間值的字符串。熊貓條件聲明和添加列
state time
ca 1
ca 5
ca 7
ca 10
for rows in df:
if df[time]>=1:
return "do nothing"
elif df[time]<=5:
return "add more"
elif df[time]<=10:
return "add less"
else:
return "error"
您有更具體的問題或錯誤嗎? – Legman
請接受解決您的問題的答案 – JoYSword