是否可以在 s3 中将 Parquet 文件从一个文件夹读取和写入另一个文件夹,而无需使用 pyarrow.
这是我的代码:
import pyarrow.parquet as pq
import pyarrow as pa
import s3fs
s3 = s3fs.S3FileSystem()
bucket = 'demo-s3'
pd = pq.ParquetDataset('s3://{0}/old'.format(bucket), filesystem=s3).read(nthreads=4).to_pandas()
table = pa.Table.from_pandas(pd)
pq.write_to_dataset(table, 's3://{0}/new'.format(bucket), filesystem=s3, use_dictionary=True, compression='snappy')
最佳答案
如果您不想直接复制文件,看来您确实可以避免使用 Pandas :
table = pq.ParquetDataset('s3://{0}/old'.format(bucket),
filesystem=s3).read(nthreads=4)
pq.write_to_dataset(table, 's3://{0}/new'.format(bucket),
filesystem=s3, use_dictionary=True, compression='snappy')
关于python - Pyarrow 从 s3 读/写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49513152/