Search code examples
trim

Removing space at the end of string


I would want to remove white spaces at the end of the string. I used below code but it doesn't work, also it does not throw any error.

df[ABC_Col].str.strip()

ABC_Col is the column header

Could you please help me on this?

Thank you


Solution

  • You need to assign the result of strip to the data frame column on the left hand side:

    df[ABC_Col] = df[ABC_Col].str.strip()