Python:将 pandas 数据框保存到实木复合地板文件中 [英] Python: save pandas data frame to parquet file

查看:128
本文介绍了Python:将 pandas 数据框保存到实木复合地板文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将熊猫数据框直接保存到实木复合地板文件中? 如果没有,建议的程序是什么?

Is it possible to save a pandas data frame directly to a parquet file? If not, what would be the suggested process?

目标是能够将镶木地板文件发送给另一个团队,他们可以使用scala代码读取/打开它.谢谢!

The aim is to be able to send the parquet file to another team, which they can use scala code to read/open it. Thanks!

推荐答案

Pandas具有核心功能to_parquet().只需将数据帧编写为镶木地板格式,如下所示:

Pandas has a core function to_parquet(). Just write the dataframe to parquet format like this:

df.to_parquet('myfile.parquet')

您仍然需要安装镶木地板库,例如fastparquet.如果您安装了多个实木复合地板库,则还需要指定要使用大熊猫的引擎,否则它将安装第一个要安装的大熊猫引擎(如

You still need to install a parquet library such as fastparquet. If you have more than one parquet library installed, you also need to specify which engine you want pandas to use, otherwise it will take the first one to be installed (as in the documentation). For example:

df.to_parquet('myfile.parquet', engine='fastparquet')

这篇关于Python:将 pandas 数据框保存到实木复合地板文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆