'How to read parquet files into array of python dictionary?
Is there a way to convert parquet files into an array of python dictionaries where the keys are the columns?
import pyarrow.parquet as pq
Does that library natively support that feature?
Solution 1:[1]
Use to_pylist
import pandas as pd
import pyarrow.parquet as pq
df = pd.concat(
[
pd.Series([1, 2, 3], name='col1'),
pd.Series(["abc", "def", "ghi"], name='col2')
],
axis=1
)
df.to_parquet('df.parquet')
pq.read_table('df.parquet').to_pydict()
>>> {'col1': [1, 2, 3], 'col2': ['abc', 'def', 'ghi']}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | 0x26res |
