如何在不循环的情况下为多个列设置值?
df.loc[:, ['test2', 'test3']] = 0
或
df[['test2', 'test3']] = 0
我希望它在“test2”和“test3”列中设置值 0,但它返回错误,df 中没有这样的列。
最佳答案
关于python - 如何在没有循环的情况下为多列设置值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56292593/
如何在不循环的情况下为多个列设置值?
df.loc[:, ['test2', 'test3']] = 0
或
df[['test2', 'test3']] = 0
我希望它在“test2”和“test3”列中设置值 0,但它返回错误,df 中没有这样的列。
最佳答案
关于python - 如何在没有循环的情况下为多列设置值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56292593/