我有一个pandas
数据帧,看起来像这样:
id c1 c2 c3
100 2 7 4
100 3 4 1
100 4 0 10
105 2 3 4
105 3 6 8
105 4 9 2
115 2 1 0
115 3 7 14
115 4 0 20
现在我想用new_id = id + 10
重复这个数据帧的行,如果这个new_id
已经存在于原始数据帧中,那么new_id = new_id(the repeated one) + 10
样品:
id c1 c2 c3
100 2 7 4
100 3 4 1
100 4 0 10
105 2 3 4
105 3 6 8
105 4 9 2
115 2 1 0
115 3 7 14
115 4 0 20
## Repeated data
110 2 7 4
110 3 4 1
110 4 0 10
##Since 115 already exists it shall now be 125, if 125 exists it shall be 135
125 2 3 4
125 3 6 8
125 4 9 2
.
.
.
您可以先将10添加到id列,如果新id已经存在,则再添加10。你知道吗
如果我没听错你的问题,看看这个。你知道吗
相关问题 更多 >
编程相关推荐