给定以下数据帧,
输入df:
cost_center | Pool_costs | 90272 |
---|---|
92705 | |
98754 | |
91350 |
iuc,可以使用isin
filt = df['Cost_centre'].isin([90272, 91350])
df.loc[filt, 'Pool_costs'] = 'B'
print(df)
Cost_centre Pool_costs
0 90272 B
1 92705 A
2 98754 A
3 91350 B