【发布时间】:2023-01-31 01:19:07
【问题描述】:
我想从这样的单词中删除空格:
str1 = "101 - purple cloths"
str1sp = removespace(srt1)
print(str1sp)
>>>>> 101-purple cloths
结果应该只去掉连字符 (-) 周围的空格。这将对整个列完成。
【问题讨论】:
-
df['column'] = df['column'].str.replace('\s-\s', '-') -
谢谢,成功了! @广黄
标签: python-3.x pandas removing-whitespace