使用案例如下:
我一直在尝试在内存中执行第二步(不需要将文件存储到磁盘以获得parquet格式),但到目前为止,我看到的所有库都是写入磁盘的。
因此,我有以下问题:
发布于 2019-06-05 02:35:34
Apache Arrow和pyarrow库应该可以解决这个问题,并在内存中完成大部分处理。在pandas
中,您可以通过pyarrow
读/写镶木面板文件。
一些示例代码也利用了smart_open。
import pandas as pd
import boto3
from smart_open import open
from io import BytesIO
s3 = boto3.client('s3')
# read parquet file into memory
obj = s3.get_object(Bucket=bucket, Key=key)
df = pd.read_parquet(BytesIO(obj['Body'].read()), engine='pyarrow')
# do stuff with dataframe
# write parquet file to s3 out of memory
with open(f's3://{outputBucket}/{outputPrefix}{additionalSuffix}', 'wb') as out_file:
df.to_parquet(out_file, engine='pyarrow', index=False)
https://stackoverflow.com/questions/52945609
复制相似问题