【发布时间】:2022-01-01 21:22:23
【问题描述】:
Str.replace 方法返回属性错误。
dc_listings['price'].str.replace(',', '')
AttributeError: Can only use .str accessor with string values, which use np.object_ dtype in pandas
这是我的价格列的前 5 行。
此堆栈溢出thread recommends 以检查我的列是否具有 NAN 值,但我的列中的值不是 NAN。
【问题讨论】:
-
你的专栏是
float,所以你不能在上面使用字符串方法。此外,由于它是一个浮点列,因此它不会包含','。