我要根据上一行的增量值在“最后一个唯一ID”列中填充值
**input is**
Channel last unique id
0 MYNTRA MN000351370
1 NYKAA NYK00038219
2 NYKAA NaN
3 NYKAA NaN
4 NYKAA NaN
5 NYKAA NaN
6 MYNTRA NaN
7 MYNTRA NaN
8 MYNTRA NaN
9 MYNTRA NaN
10 MYNTRA NaN
11 MYNTRA NaN
Expected output
Channel last unique id
0 MYNTRA MN000351370
1 NYKAA NYK00038219
2 NYKAA NYK00038220
3 NYKAA NYK00038221
4 NYKAA NYK00038222
5 NYKAA NYK00038223
6 MYNTRA MN000351371
7 MYNTRA MN000351372
8 MYNTRA MN000351373
9 MYNTRA MN000351374
10 MYNTRA MN000351375
11 MYNTRA MN000351376
希望你明白问题所在
3条答案
按热度按时间2vuwiymt1#
您可以使用
groupby.cumcount
来递增数字,并将其加到数字部分:输出量:
u4dcyp6a2#
示例
df值
代码
结果(
df
):5cnsuln73#
下面是如何通过填充零获得所需的输出,以使id始终保持固定长度11。
第一个