python - CSV to Feather in Pandas with slicing Rows
问题描述
我正在处理一个巨大的 CSV 数据集(5000 万行)。我正在尝试对其进行切片并将其保存为羽毛格式,以便在稍后加载羽毛格式时节省一些内存。
作为一种解决方法,我将数据块加载为 CSV 文件,然后将其合并到一个数据框中。
这是我到目前为止所尝试的:
df[2000000:4000000].to_feather('name')
我收到以下错误:
ValueError: feather does not support serializing a non-default index for the index; you can .reset_index() to make the index into column(s)
然后我尝试重置索引,但仍然出现同样的错误。
解决方案
尝试.loc
:
df.loc[2000000:4000000].reset_index().to_feather("./myfeather.ftr")
您必须重置索引才能将数据帧保存为羽化格式。为我工作。
推荐阅读
- javascript - 混合类型的地图功能中的打字稿类型问题反应
- python - 如何在 PyQt 中嵌入 scikitplot?
- c++ - 带有连接控制块和自定义删除器的 std::shared_ptr
- javascript - 跨电子表格中的特定工作表运行脚本
- sip - Tokbox SIP 与 Nexmo 的会议集成
- javascript - 不匹配的文件格式和扩展名:用javascript生成的excel
- xml - 如何修复 Excel 中的“所选 XML 架构包含多个根节点”提示
- ios - 锁定屏幕播放/暂停控件未更改
- windows - Windows下的核心转储?
- javascript - Azure Function + Javascript 如何获取我在 post 请求中传递的数据?