Pandas 2.0.0 似乎thousands=','
在解析Int64
对象时没有正确考虑:
import io
pd.read_csv(io.StringIO('''a\n22,922'''), sep='\t', dtype={'a': 'Int64'}, thousands=',')
具体错误是:
Traceback (most recent call last):
File pandas/_libs/lib.pyx:2280 in pandas._libs.lib.maybe_convert_numeric
ValueError: Unable to parse string "22,922"
是否有一种解决方法不涉及返回到 un-nullableint
或转换为float
?我已经确认这适用于旧的 dtypesdtype={'a': 'int'}
和dtype={'a': 'float'}
.