Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

remove leading and lagging spaces dataframe python

df = df.applymap(lambda x: x.strip() if isinstance(x, str) else x)
print (df)
                     A    B     C
0                  A b    2   3.0
1                  NaN    2   3.0
2               random   43   4.0
3  any txt is possible  2 1  22.0
4                        23  99.0
5                 help   23   NaN
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #leading #lagging #spaces #dataframe #python
ADD COMMENT
Topic
Name
1+7 =