使用pyarrow如何将其附加到镶木地板文件中?

梅林:

您如何使用附加/更新parquet文件pyarrow

import pandas as pd
import pyarrow as pa
import pyarrow.parquet as pq


 table2 = pd.DataFrame({'one': [-1, np.nan, 2.5], 'two': ['foo', 'bar', 'baz'], 'three': [True, False, True]})
 table3 = pd.DataFrame({'six': [-1, np.nan, 2.5], 'nine': ['foo', 'bar', 'baz'], 'ten': [True, False, True]})


pq.write_table(table2, './dataNew/pqTest2.parquet')
#append pqTest2 here?  

我在文档中找不到有关添加镶木地板文件的任何内容。并且,可以pyarrow与多处理一起使用来插入/更新数据

易卜拉欣易卜拉欣:

我遇到了同样的问题,我认为可以使用以下方法解决它:

import pandas as pd
import pyarrow as pa
import pyarrow.parquet as pq


chunksize=10000 # this is the number of lines

pqwriter = None
for i, df in enumerate(pd.read_csv('sample.csv', chunksize=chunksize)):
    table = pa.Table.from_pandas(df)
    # for the first chunk of records
    if i == 0:
        # create a parquet write object giving it an output file
        pqwriter = pq.ParquetWriter('sample.parquet', table.schema)            
    pqwriter.write_table(table)

# close the parquet writer
if pqwriter:
    pqwriter.close()

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何使用Pyarrow更改镶木地板文件中的列名?

如何使用 pyarrow 流式处理镶木地板?

使用pyarrow读取镶木地板文件时如何解码字典列?

如何附加到镶木地板文件以及它如何影响分区?

使用 PyArrow 从多个文件中读取分区的镶木地板数据集,并根据文件名添加分区键

如何将小的镶木地板文件合并为一个大的镶木地板文件?

如何使用Spark(pyspark)编写镶木地板文件?

如何使用 Pyspark 并行处理多个镶木地板文件?

在 nodejs 中读取镶木地板文件

如何使用Spark将镶木地板文件加载到Hive表中?

如何使用Databricks将.rdata文件转换为Azure数据湖中的镶木地板?

PyArrow:使用嵌套类型在镶木地板中存储字典列表

如何在C ++中的镶木地板文件中保存时间戳并将其加载到Python Pandas中?

如何将 s3 中的文件夹中的所有镶木地板文件读取到 Pandas

如何将记录从镶木地板写入另一个镶木地板?

使用镶木地板工具打开镶木地板文件时出错

使用镶木地板格式附加Apache Spark中的列描述

如何将镶木地板文件复制并转换为CSV

如何将 ndarray/多维数组转换为镶木地板文件?

如何将镶木地板格式的文件加载和索引到elasticsearch?

如何可靠地使用镶木地板文件中的日期时间值来填充(雪花)表

使用 fastparquet 在子文件上划分镶木地板文件

如何在python中的S3中从pandas数据帧写入镶木地板文件

如何处理大量的镶木地板文件

在Spark中同时读取几个镶木地板文件

在Spark中获取镶木地板目录的源文件

在AWS Glue中读取镶木地板文件

复制镶木地板文件,然后使用 Athena 查询它们

使用通配符通过火花读取镶木地板文件