【发布时间】:2020-01-03 00:58:20
【问题描述】:
您好,尝试根据多个条件更新数据框中的值。如果有低于 30 美元的 Gas/Fuel 类别,我想将类别更改为食品。
data.loc[60:65,['Category','Debit']]
Category Debit
60 Groceries 38.18
61 Gas/Fuel 7.30
62 Fast Food 9.18
63 Pharmacy 7.03
64 Gas/Fuel 3.16
65 Pharmacy 9.40
for index, row in data.iterrows():
if row[3] == 'Gas/Fuel' and row[4] < 30:
row[3]='Fast Food'
【问题讨论】: