我试图向所有重复的值添加一个后缀-US
,并且additoanlcountry
列等于US
。下面是我的数据帧df
的一个片段
product_num country
101 US
101 Ireland
302 US
303 Scotland
304 France
305 US
305 Germany
306 US
307 US
我期望的输出如下所示
product_num country
101-US US
101 Ireland
302 US
303 Scotland
304 France
305-US US
305 Germany
306 US
307 US
通过将所有重复项的^{} 与} 进行比较,并仅将筛选的行设置为添加后缀字符串的字符串:
keep='False'
链接来创建掩码,并将country
列与^{使用^{} 的替代解决方案:
相关问题 更多 >
编程相关推荐