I think its simple question but i have problem with it.
How can I delete spaces in multiple columns at once in pandas dataframe? example df:
A, B, C, D, E
d,d ,s,s,a
a ,a ,s,a ,r
I want to remove space in columns :A,B,D,E
normally i am using this method :
df['col']=df['col'].apply(lambda x: x.strip())
extending this one above i tried to use :
df[['A','B','D','E']]=df[['A','B','D','E']].apply(lambda x : x.strip())
but I am receiving an error:
AttributeError: ("'Series' object has no attribute 'strip'"
how to solve it?
additionally Removing space from dataframe columns in pandas this one is not a duplicate, its only for columns names