如何将Parquet转换为JSON

3
我需要下载并将托管在S3上的Parquet文件转换为JSON。过去,我可以使用SQL使用select_object_content将某些文件输出为JSON。但是,对于更大的文件,它会超时,因此我需要找到更快的方法。
我已经尝试了以下方法:
df = pd.read_parquet(s3_location)
df = df.to_json(orient="records")

然而,上述代码的JSON输出包含键路径 (hotels.date.hotel_price),而不是 hotels:{date:{hotel_price: 100}} 这样的格式。

请问有没有一种方法可以使其以第二种JSON格式输出?


不需要的话,请远离熊猫。 - Lucas Tieman
导入pyarrow.paraquet作为pq pq.read_table('df.parquet').to_pydict() - Lucas Tieman
此外,Polars使用Rust paraquat reader来支持分页。https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.read_parquet.html - Lucas Tieman
1个回答

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接