-
-
Save cristlee/9f9ef106dcb84642fd74ba538256d071 to your computer and use it in GitHub Desktop.
Read Avro file from Pandas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas | |
import fastavro | |
def avro_df(filepath, encoding): | |
# Open file stream | |
with open(filepath, encoding) as fp: | |
# Configure Avro reader | |
reader = fastavro.reader(fp) | |
# Load records in memory | |
records = [r for r in reader] | |
# Populate pandas.DataFrame with records | |
df = pandas.DataFrame.from_records(records) | |
# Return created DataFrame | |
return df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment