【问题标题】:Pandas and FastParquet read a single partitionPandas 和 FastParquet 读取单个分区
【发布时间】:2020-02-08 12:46:02
【问题描述】:

我有一个长时间运行的工作要读取在美国州具有自然逻辑分区的数据集。我使用 fastparquet(使用 pd.write_parquet)将它保存为 pandas 的分区 parquet 数据集。

我希望我的好友能够从创建的 parquet 文件夹中读取单个分区(状态)。 read_parquet 没有过滤能力。有什么想法吗?

【问题讨论】:

    标签: python pandas parquet pyarrow fastparquet


    【解决方案1】:

    尝试使用daskparquet 阅读器。通过pandas 过滤对我有用。

    How to read parquet file with a condition using pyarrow in Python

    RUN pip install pyarrow
    RUN pip install "dask[complete]"
    
    import pyarrow.parquet as pq
    import dask.dataframe as dd
    import pandas as pd
    
    path = ""
    dask_df = dd.read_parquet(path, columns=["col1", "col2"], engine="pyarrow")
    
    dask_filter_df = dask_df[dask_df.col1 == "filter here"]
    
    path = ""
    parquet_pandas_df = pq.ParquetDataset(path).read_pandas().to_pandas()
    
    pandas_filter_df = parquet_pandas_df[parquet_pandas_df.col1 == "filter here"]
    

    【讨论】:

      猜你喜欢
      • 2021-01-22
      • 2018-06-18
      • 1970-01-01
      • 2018-06-07
      • 1970-01-01
      • 2018-07-17
      • 1970-01-01
      • 2017-03-13
      • 2019-07-05
      相关资源
      最近更新 更多