Registry / serialization / pandavro

pandavro

JSON →
library1.9.0pypypi✓ verified 82d ago

Pandavro provides a convenient interface to read and write Avro files using pandas DataFrames. It simplifies the serialization and deserialization of tabular data between Python's pandas library and the Avro data format. The current version is 1.9.0, and it maintains an active release schedule with updates for Python, pandas, and NumPy compatibility.

pip install pandavro
INSTALL
IMPORT
SIG · PANDAVRO
P
pandavro
serializationpythonv1.9.0
Install
8.2s avg
Import
910ms
Disk
179MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.9.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.924s · 172.7MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 8.2s · import 0.895s · 169MB
179MB installed
● package 179MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

to_avro
from pandavro import to_avro
import pandavro as pa
read_avro
from pandavro import read_avro
import pandavro as pa
from_avro
from pandavro import from_avro
import pandavro as pa

This quickstart demonstrates how to create a pandas DataFrame, write it to an Avro in-memory stream using `pandavro.to_avro()`, and then read it back into a new DataFrame with `pandavro.read_avro()`.

import pandas as pd import pandavro as pa import io # 1. Create a pandas DataFrame df = pd.DataFrame({ 'id': [1, 2, 3], 'name': ['Alice', 'Bob', 'Charlie'], 'value': [10.1, 20.2, 30.3] }) print("Original DataFrame:") print(df) # 2. Write DataFrame to an Avro file (using BytesIO for in-memory example) output_buffer = io.BytesIO() pa.to_avro(output_buffer, df, name="my_record") # 'name' is recommended for the root record # 3. Read Avro data back into a DataFrame output_buffer.seek(0) # Reset buffer position for reading read_df = pa.read_avro(output_buffer) print("\nRead DataFrame from Avro:") print(read_df) # You can also use file paths directly: # pa.to_avro('output.avro', df) # loaded_df = pa.read_avro('output.avro')
Debug
Known issues
breakingVersion 1.9.0 introduces official support for pandas 2.0 and NumPy 2.0. While `pandavro` itself is adapted, upgrading these underlying libraries in your environment might introduce breaking changes in your own code, especially regarding pandas' copy-on-write behavior or NumPy's API changes.
fix
Review your application's reliance on pandas/NumPy internals and behavior when upgrading to pandas 2.0+ or NumPy 2.0+. Test thoroughly after upgrading underlying dependencies.
affects: >=1.9.0
gotcha`pandavro` infers Avro schemas from pandas DataFrames. This inference might not perfectly align with pre-existing Avro schemas or desired Avro types, particularly for mixed-type columns, generic `object` dtypes, or specific handling of `NaN`/`None` values, leading to unexpected schemas or data type conversions.
fix
Inspect the inferred schema if schema compatibility is critical (e.g., by writing to a file and examining it with an Avro tool). Pre-process your DataFrame to ensure consistent dtypes for columns before writing, or explicitly cast types to match your desired Avro schema.
affects: All versions
gotchaHandling of `NaN` (Not a Number) and `None` values can lead to subtle issues. `pandavro` typically maps `NaN` in numeric columns to `null` within an Avro union type (e.g., `["null", "double"]`). However, `None` in `object` columns might result in `string` or `bytes` types depending on other data, potentially causing schema mismatches.
fix
Standardize `NaN` and `None` handling in your DataFrame. Use `df.fillna()` or explicit type conversions (e.g., `pd.Int64Dtype()`) to ensure consistent nullable types. For `object` columns, ensure all non-null values are of a consistent type that maps well to Avro (e.g., all strings).
affects: All versions
Upgrade
Version history
1.9.0latest on PyPI · released Aug 27, 2025
Audit
Dependencies
pandasrequiredCore dependency for DataFrame operations.
fastavrorequiredBackend Avro serialization/deserialization library.
Agent activity
10 hits · last 30 days
node
6
Amazon
1
Resources
pandavro — pip install pandavro · libregistry