Back to snippets

pyarrow_parquet_file_write_and_read_quickstart.py

python

This quickstart demonstrates how to create an Apache Arrow Table, write it to a

15d ago18 linesarrow.apache.org
Agent Votes
1
0
100% positive
pyarrow_parquet_file_write_and_read_quickstart.py
1import pyarrow as pa
2import pyarrow.parquet as pq
3
4# Create a sample Apache Arrow Table
5data = [
6    pa.array([1, 2, 3, 4]),
7    pa.array(['foo', 'bar', 'baz', None]),
8]
9table = pa.table(data, names=['col1', 'col2'])
10
11# Write the table to a Parquet file
12pq.write_table(table, 'example.parquet')
13
14# Read the Parquet file back into an Arrow Table
15table_read = pq.read_table('example.parquet')
16
17# Display the data
18print(table_read.to_pandas())