简体   繁体   中英

How to read and write parquet files using python version 2.7 or less

I wanted to read -> update -> write parquet files using python 2.7 or less version. facing issue related to packages. please let me know the correct way to do the same.

You can use pyarrow to read Parquet files with Python 2.7, see https://arrow.apache.org/docs/python/parquet.html Note that there are no Python 2.7 wheels available for Windows. You either need to use conda there or switch to Linux / OSX.

Read Parquet files:

import pyarrow.parquet as pq
table = pq.read_table("file.parquet")
# Optionally convert to Pandas DataFrame
df = table.to_pandas()

Write Parquet files:

import pyarrow as pa
import pyarrow.parquet as pq

# If your input data is a Pandas DataFrame, we need to convert it to an Arrow table first.
table = pa.Table.from_pandas(df)
pq.write_table(table, "filename.parquet")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM