我首先尝试用 0 替换所有具有“LOSE”的值。df.mask(df == 'LOSE', 0,inplace=True)这很好用。我想用 1 替换多个值。df.mask(df in ['WIN','FREE','PENALTY','DRAW'],1, inplace=True)这不起作用:ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().关于如何表达替换数据框中的多个值的任何想法。
添加回答
举报
0/150
提交
取消
