Removing Whitespace or Characters from a Dataframe Column

Python

 1|  # remove whitespace from all strings in the Name column
 2|  df['Name'] = df['Name'].str.strip()
 3|  
 4|  # remove all commas from the Name column
 5|  df['Name'] = df['Name'].str.strip(",")
Did you find this snippet useful?

Sign up for free to to add this to your code library