Traditional text-based formats like Comma-Separated Values (CSV) and Microsoft Excel suffer from slow read/write performance, large disk storage footprints, and type loss during persistence. Apache Parquet and Feather (Apache Arrow) solve these limitations by providing binary columnar storage with strict Schema and Data Type preservation.
Show Table of Contents ↓Choose the optimal storage format based on your operational requirements across speed, compression, and schema fidelity:
| Feature | CSV | Parquet | Feather (Arrow) |
|---|---|---|---|
| Storage Layout | Row-oriented (Text) | Columnar (Binary) | Columnar (In-Memory Binary) |
| Read/Write Speed | Slow | Fast | Ultra-Fast (Instant I/O) |
| Disk Compression | None (or Gzip) | High (Snappy, Zstd) | Moderate (LZ4, Zstd) |
| Schema Preservation | No (Types inferred) | Yes (Strict PyArrow schema) | Yes (Exact pandas types) |
| Best Use Case | Human inspection, legacy systems | Long-term cloud storage (S3, GCS) | Ephemeral local cache, IPC between R/Python |
To use Parquet in Pandas, ensure pyarrow or fastparquet is installed. Use df.to_parquet() and pd.read_parquet():
import pandas as pd
import numpy as np
# Generate synthetic DataFrame
df = pd.DataFrame({
"id": np.arange(1, 100001),
"category": np.random.choice(["A", "B", "C", "D"], 100000),
"sales": np.random.uniform(10.0, 500.0, 100000),
"timestamp": pd.date_range(start="2026-01-01", periods=100000, freq="min")
})
# Save DataFrame to Parquet file
df.to_parquet("data.parquet", index=False)
# Read Parquet file back into DataFrame
df_loaded = pd.read_parquet("data.parquet")
print(df_loaded.info())
Parquet supports several compression algorithms via the compression parameter:
# Save with zstd compression for high efficiency
df.to_parquet("data_zstd.parquet", compression="zstd", index=False)
Feather is an uncompressed or lightly compressed memory-mapped format built on Apache Arrow. It provides near-instantaneous load times for local session caching:
# Export to Feather format
df.to_feather("cache.feather")
# Load instantly from Feather
df_cached = pd.read_feather("cache.feather")
You can collect sample student benchmark tables across various formats directly from plus2net Student Benchmark Dataset and convert them to optimized Parquet binary files:
import pandas as pd
# Download sample datasets from plus2net server inside Google Colab
# !wget https://www.plus2net.com/python/download/student.csv
# !wget https://www.plus2net.com/python/download/student.xlsx
# !wget https://www.plus2net.com/python/download/student.json
# !wget https://www.plus2net.com/python/download/student.xml
# !wget https://www.plus2net.com/python/download/my_db.db
# Load CSV format and convert to Parquet
df_student = pd.read_csv("https://www.plus2net.com/python/download/student.csv")
# Export ingested student records into Parquet binary storage
df_student.to_parquet("student.parquet", index=False)
# Verify Parquet reload
df_student_pq = pd.read_parquet("student.parquet")
print(df_student_pq.head())
ImportError: Unable to find a valid parquet library: Triggered when neither pyarrow nor fastparquet is installed. Fix: Run pip install pyarrow.ArrowInvalid: System time before epoch: Occurs when saving nanosecond timestamps. Fix: Pass coerce_timestamps="ms" or allow_truncated_timestamps=True in to_parquet().Cannot serialize mixed object dtypes: Occurs when a string column contains mixed non-string objects. Fix: Cast string columns using df['col'] = df['col'].astype(str) prior to export.Parquet is a columnar format optimized for selecting specific columns across millions of rows. For single-row lookup operations, relational SQL databases or key-value stores are faster.
Parquet focuses on high disk compression and long-term storage, whereas Feather focuses on zero-copy memory mapping and ultra-fast session caching.
Parquet files are immutable. To append data, write new data as partitioned files inside a directory dataset or read, concatenate, and overwrite the file in Pandas.
When comparing disk sizes across formats for a dataset with 100,000 rows:
Perform the following task:
item_id, price, and transaction_date.transactions.parquet using snappy compression.item_id and price columns using columns=['item_id', 'price'] in pd.read_parquet().import pandas as pd
import numpy as np
np.random.seed(42)
df_tx = pd.DataFrame({
"item_id": np.random.randint(1000, 9999, size=50000),
"price": np.random.round(np.random.uniform(5.0, 250.0, size=50000), 2),
"transaction_date": pd.date_range(start="2026-01-01", periods=50000, freq="s")
})
# 2. Export to Parquet
df_tx.to_parquet("transactions.parquet", compression="snappy", index=False)
# 3. Read selective columns
df_sub = pd.read_parquet("transactions.parquet", columns=["item_id", "price"])
# 4. Verify shape and content
print(f"Subset Shape: {df_sub.shape}")
print(df_sub.head())
assert df_sub.shape == (50000, 2)
Explore interactive code cells, dynamically test Parquet/Feather benchmarks, convert sample student datasets, troubleshoot common errors, and run self-validating assertions.
View on GitHubReference: Pandas IO Tools official user guide.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.