您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

pandas:用另一个字符串替换字符串

pandas:用另一个字符串替换字符串

解决方案与replace通过dictionary

df['prod_type'] = df['prod_type'].replace({'respon':'responsive', 'r':'responsive'})
print (df)
    prod_type
0  responsive
1  responsive
2  responsive
3  responsive
4  responsive
5  responsive
6  responsive

如果需要将列中的所有值设置为一些string

df['prod_type'] = 'responsive'
其他 2022/1/1 18:31:38 有561人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶