我只想更改特定colomn中的值
gene scaf GC other
gene1 3456 78 other1
gene2 7898 56 other 2
gene3 5667 23 other 3
等 我想在每个基因名称添加以下数字:_number1 得到:
gene scaf GC other
gene1_number1 3456 78 other1
gene2 7898 56 other 2
gene3 5667 23 other 3
谢谢大家。
答案 0 :(得分:1)
您可以按条件添加字符串:
df.loc[df['gene'] == 'gene1', 'gene'] += '_number1'
print (df)
gene scaf GC other
0 gene1_number1 3456 78 other1
1 gene2 7898 56 other 2
2 gene3 5667 23 other 3