我想使用.ftr文件来快速分析数百个表。不幸的是,我在使用小数和千位分隔符时遇到了一些问题,类似于that post,只是read_feather不允许使用decimal=',', thousands='.'
选项。我尝试了以下方法:
df['numberofx'] = df['numberofx'].apply(lambda x: x.str.replace(".","", regex=True).str.replace(",",".", regex=True))
导致
AttributeError: 'str' object has no attribute 'str'
当我将其更改为]时>
df['numberofx'] = df['numberofx'].apply(lambda x: x.replace(".","").replace(",","."))
我在结果中收到一些奇怪的(四舍五入)错误,例如对于某些大于1k的数字,则为22359999999999998而不是2236。所有低于1k的值都是实际结果的10倍,这可能是因为删除了“。”。浮点数并创建该数字的整数。
正在尝试
df['numberofx'] = df['numberofx'].str.replace('.', '', regex=True)
还会导致结果出现一些奇怪的现象,因为某些数字在10 ^ 12处,而其他数字则应保持在10 ^ 3。
Here is how I create my .ftr files from multiple Excel files。我知道我可以简单地从Excel文件创建DataFrames,但这会使我的日常计算速度变慢。
我该如何解决这个问题?
我想使用.ftr文件来快速分析数百个表。不幸的是,我对小数和千位分隔符有一些问题,类似于该帖子,只是read_feather不允许...
您的代码中的问题是: