删除字符串末尾的 space

Removing space at the end of string

我想删除字符串末尾的空格。我使用了下面的代码,但它不起作用,也没有抛出任何错误。

df[ABC_Col].str.strip()

ABC_Col 是列 header

你能帮我解决这个问题吗?

谢谢

您需要将 strip 的结果分配给左侧的数据框列:

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