【发布时间】:2020-07-07 07:31:19
【问题描述】:
我有一个列如下的数据框;
ID, Quantity
1 1,000 total
2 802 destroyed
3 >689 total
4 1,234-1,900 lost
我希望输出如下:
ID, Quantity
1 1,000
2 802
3 689
4 1234-1,900
我试过了,
df['Quantity'] = df['Quantity'].str.replace(r' \s', '')
目前没有成功。
【问题讨论】:
标签: python string dataframe replace integer