首页 > 解决方案 > ArrowNotImplementedError:在数据帧上应用 pandas.to_feather 时出现半浮动错误

问题描述

我有一个数据框,其中包含不同数据类型的列,包括日期。不做了一些修改后,我想将它保存为羽毛文件以便以后访问它。但是我在以下步骤中遇到了错误

historical_transactions.to_feather('tmp/historical-raw')

ArrowNotImplementedError: halffloat

标签: pythonpandasfeather

解决方案


你可以试试这个:

    historical_transactions.astype('float32').to_feather('tmp/historical-raw')

请注意,如果您还有无法转换为 float32 的字段,则上述行可能会失败。为了忽略这些列并保持原样,请尝试:

    historical_transactions.astype('float32', errors='ignore').to_feather('tmp/historical-raw')

Feather 格式依赖于 Pyarrow,而 Pyarrow 又依赖于 Apache Parquet 格式。关于浮点格式,它只支持浮点(32)和双精度(64)。不知道这对你来说有多大的意义,但在 GitHub 中还有一个自动“强制箭头半精度浮点数到 float32”的公开请求。

有关详细信息,请参见此处此处


推荐阅读