【问题标题】:Using PANDAS to conditionally manipulate specific cells based on another cell and getting it to change original df使用PANDAS根据另一个单元格有条件地操作特定单元格并让它改变原始df
【发布时间】:2022-07-29 10:07:21
【问题描述】:
andrew_ramirez[andrew_ramirez['Datacenter'].isin(['ATL2','ACT1'])]['payout']*= 0.25

这不会根据标准更改我的数据框(名为 andrew_ramirez)。我错过了什么吗?

【问题讨论】:

标签: pandas


【解决方案1】:

您可以从此代码中使用:

df['payout']=np.select([df.Datecenter.isin(['ATL2', 'ACT1']), [df.payout*0.25], df.payout)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-21
    • 2021-05-30
    • 2021-05-21
    • 2013-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多