Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas strips spaces in dataframe

df_obj = df.select_dtypes(['object'])
print (df_obj)
0    a  
1    c  

df[df_obj.columns] = df_obj.apply(lambda x: x.str.strip())
print (df)

   0   1
0  a  10
1  c   5
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #strips #spaces #dataframe
ADD COMMENT
Topic
Name
3+8 =