Python 3.x 基于其他字段的值更改字段的值

Python 3.x 基于其他字段的值更改字段的值,python-3.x,pandas,Python 3.x,Pandas,我有一个名为“qtm”的数据帧,如下所示: 名称 力量 弱点 百兽王 楠 花 乔 用拳猛击 糖果 百兽王 速度 时间 通过以下方式添加缺少测试值的括号: 或通过掩码用于设置NaNs: #one condition () not necessary m = qtm['Name'] == 'Voltron' qtm.loc[m, 'Strength'] = qtm.loc[m, 'Strength'].fillna('Fire') 这起作用了。例如,如果我正在寻找的强度值是'not avail'而

我有一个名为“qtm”的数据帧,如下所示:

名称 力量 弱点 百兽王 楠 花 乔 用拳猛击 糖果 百兽王 速度 时间
通过以下方式添加缺少测试值的括号:

或通过掩码用于设置
NaN
s:

#one condition () not necessary
m = qtm['Name'] == 'Voltron'
qtm.loc[m, 'Strength'] = qtm.loc[m, 'Strength'].fillna('Fire')

这起作用了。例如,如果我正在寻找的强度值是'not avail'而不是NaN,那么将df=='not avail'等同是否也有效?@ThatGuyXY-是,然后使用
(qtm['Strength']=='not avail')
#one condition () not necessary
m = qtm['Name'] == 'Voltron'
qtm.loc[m, 'Strength'] = qtm.loc[m, 'Strength'].fillna('Fire')