Advertisement
elena1234

strip all strings of a dataframe in Python

Jul 25th, 2023
773
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.12 KB | Source Code | 0 0
  1. data_obj = data.select_dtypes(['object'])
  2. data[data_obj.columns] = data_obj.apply(lambda x: x.str.strip())
  3. data.head()
  4.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement