猿问
对 pandas 中每个单元格内的字母进行排序
我有这个数据框:
AB DC BA WZ DC ZW
我想使用 pandas 对每个单元格的字母进行排序,如下所示:
AB CD AB WZ CD WZ
谢谢!
慕丝7291255
浏览 105
回答 2
2回答
摇曳的蔷薇
尝试df = df.applymap(lambda x : ''.join(sorted(list(x)))) col1 col20 AB CD1 AB WZ2 CD WZ
0
0
0
拉风的咖菲猫
使用:df.applymap(lambda x: ''.join(sorted(x)))
0
0
0
随时随地看视频
慕课网APP
相关分类
Python
我要回答