Python: I want to add a column to a df where if a certain value is 0, return 1 else return the original value of the column

后端 未结 0 810
眼角桃花
眼角桃花 2021-01-28 09:33

the Python code with which I am trying to achieve this result is:

df[\'column2\'] = np.where(df[\'column1\'] == 0, 1, df[\'column1\'])

Thanks in

相关标签:
回答
  • 消灭零回复
提交回复
热议问题