2024-04-09 18:52:00 by wst
parquet文件为列式存储格式,在python下怎么读取里面的内容呢?
今天我们来探索下读取方法:
1. 读取未压缩的parquet文件,并转换为我们熟悉的dataframe格式:
import pandas import pyarrow.parquet as pq import pandas table = pq.read_table("29bfd3.parquet") df = table.to_pandas() print(len(df)) print(df.columns)
2. 读取未压缩的parquet文件, 直接用read_parquet方法:
from pandas import read_parquet fn = "29bfd3.parquet" data = read_parquet(fn) print(type(data))
parquet是一种高效的数据存储方法,读取速度也很快。
在大数据领域也很流行,所以掌握它可以增加你的技能圈。