简体   繁体   English

如果值等于某个数字,则将值从一列复制到另一列

[英]Copy values from one column to another if values equal to a certain number

Could anyone show me how to copy values in the column( m/z ) to a new column if its value equals to 300 or 305?如果列的值等于 300 或 305,谁能告诉我如何将列( m/z )中的值复制到新列? If its value doesn't equal to 300 or 305, put 0 in the new column.如果它的值不等于 300 或 305,则在新列中输入 0。 It should look as follows.它应该如下所示。

在此处输入图像描述

You could do:你可以这样做:

df['300'] = 0
df['305'] = 0

df['300'][df['m/z'] == 300] = 300
df['305'][df['m/z'] == 305] = 305

But i'm sure there might be a better way haha但我相信可能有更好的方法哈哈

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM