I have this data frame:
AB  DC
BA  WZ
DC  ZW
And I want to sort letters of each cell using pandas, like this:
AB CD
AB WZ
CD WZ
Thanks!
Try
df = df.applymap(lambda x : ''.join(sorted(list(x))))
  col1 col2
0   AB   CD
1   AB   WZ
2   CD   WZ
                        Use:
df.applymap(lambda x:  ''.join(sorted(x)))
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With