Reputation: 45
I want to split all the columns of a dataframe with more than two whitespaces since all the columns have the same format. I know how to do the same on one or a few columns but stuck at implementing the same code on all the columns. The code below works for one column. Would really appreciate any help on this.
df2 = df1['Col 1'].str.split("\s{2,}",expand = True)
Upvotes: 1
Views: 126
Reputation: 1102
simply do this:
df = df.apply(lambda x: x.str.split("\s{2,}",expand = True))
Upvotes: 1