-2

I have many columns in my pandas data frame which I want to cleanse with a specific method. I want to see if there is a way to do this in one go.

This is what I tried and this does not work.

list = list(bigtable) # this list has all the columns i want to cleanse

for index in list:

   bigtable1.column = bigtable.column.str.split(',', expand=True).apply(lambda x: pd.Series(np.sort(x)).str.cat(sep=','), axis=1) 
Anu
  • 197
  • 1
  • 1
  • 14

1 Answers1

1

try this should work:

bigtable1=pd.Dataframe()

for index in list:

   bigtable1[index] = bigtable[index].str.split(',', expand=True).apply(lambda x: pd.Series(np.sort(x)).str.cat(sep=','), axis=1) 
shivsn
  • 7,680
  • 1
  • 26
  • 33