python – remove exta space in column

data = pd.DataFrame({'values': ['   ABC   ', '   DEF', '  GHI  ']})
      values
0     ABC   
1        DEF
2      GHI  

data['values'].str.strip()
0    ABC
1    DEF
2    GHI

Here is what the above code is Doing:
1. Create a DataFrame with a column named ‘values’.
2. The column contains strings with leading and trailing whitespace.
3. Use the str.strip() method to remove the whitespace.

Note that the str.strip() method removes all whitespace from the beginning and end of the string.