3

同じフォルダーにある複数の Parquet ファイルから Parquet ファイルを作成しました。各ファイルはパーティションに対応します。

Parquet ファイルは、さまざまなプロセスで作成されます ( Python を使用concurrent.futures)。1 つのプロセスで実行するコードの例を次に示します。

# `df` is a standard Pandas DataFrame with
# 22 columns of different types and at most 100e3 rows.

# Set the index
df.set_index("cid", inplace=True)

# Write to single file
fastparquet.write(fpath, df, compression='snappy, file_scheme='simple)

df最大で行 (および 22 列) を含み100e3、整数インデックス ( と呼ばれるcid) でインデックス付けされます。

次に、次を使用して 2 つのメタデータ ファイルを作成しました。

# `data_paths` contains the list of all the Parquet data files
# created in multiple processes.
fastparquet.writer.merge(data_paths, verify_schema=True)

実際_metadata_common_metadataすべての Parquet ファイルを含むフォルダーに正しく作成されます。

データにはインデックスが付けられているか、メタデータ ファイルが含まれているため、データのサイズなどの基本的な情報の取得は高速であるはずだと単純に考えました。たとえば、次の場合は永遠に時間がかかります。

import dask.dataframe as ds

# `dataset_path` is the path to the folder
# containing all the Parquet files created above
# and the metadata files.
# It contains ~100-200 individual Parquet files
# for a total of ~60,000,000 rows
data = df.read_parquet(dataset_path)
data.shape[0].compute()

それは例外ですか?

また、ほとんどの列はint64float64あり、いくつかの列はobject(stringサイズが異なります。

4

2 に答える 2