如何将熊猫数据帧写入.arrow文件

问题描述

如何将.arrow格式的pandas数据帧写入磁盘?我希望能够将箭here读取到Arquero中。

解决方法

由于羽毛是箭头IPC格式,因此您可以仅使用write_feather。参见http://arrow.apache.org/docs/python/feather.html

,

您可以执行以下操作:

import pyarrow as pa
import pandas as pd 

df = pd.read_parquet('your_file.parquet')

schema = pa.Schema.from_pandas(df,preserve_index=False)
table = pa.Table.from_pandas(df,preserve_index=False)

sink = "myfile.arrow"

# Note new_file creates a RecordBatchFileWriter 
writer = pa.ipc.new_file(sink,schema)
writer.write(table)
writer.close()

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...