python将DataFrame存入parquet文件中
【代码】python将DataFrame存入parquet文件中。
·
代码
import pandas as pd
import pyarrow.parquet as pq
import pyarrow as pa
out_file = 'test.parquet'
array = [1, 2, 3, 4]
df = pd.DataFrame(array)
# Create a parquet table from your dataframe
table = pa.Table.from_pandas(df)
# Write direct to your parquet file
pq.write_table(table, out_file)
# write to this dir and auto name the parquet file
out_path = './database/'
pq.write_to_dataset(table, root_path = out_path)
结果示例
pq.write_table
pq.write_to_dataset
更多推荐
已为社区贡献7条内容
所有评论(0)