pyarrow.concat_tables#

pyarrow.concat_tables(tables,MemoryPoolmemory_pool=None,strpromote_options='none',**kwargs)#

Concatenate pyarrow.Table objects.

If promote_options=”none”, a zero-copy concatenation will be performed. The schemasof all the Tables must be the same (except the metadata), otherwise anexception will be raised. The result Table will share the metadata with thefirst table.

If promote_options=”default”, any null type arrays will be casted to the type of otherarrays in the column of the same name. If a table is missing a particularfield, null values of the appropriate type will be generated to take theplace of the missing field. The new schema will share the metadata with thefirst table. Each field in the new schema will share the metadata with thefirst table which has the field defined. Note that type promotions mayinvolve additional allocations on the givenmemory_pool.

If promote_options=”permissive”, the behavior of default plus types will be promotedto the common denominator that fits all the fields.

Parameters:
tablesiterable ofpyarrow.Tableobjects

Pyarrow tables to concatenate into a single Table.

memory_poolMemoryPool, defaultNone

For memory allocations, if required, otherwise use default pool.

promote_optionsstr, defaultnone

Accepts strings “none”, “default” and “permissive”.

**kwargsdict, optional

Examples

>>>importpyarrowaspa>>>t1=pa.table([...pa.array([2,4,5,100]),...pa.array(["Flamingo","Horse","Brittle stars","Centipede"])...],names=['n_legs','animals'])>>>t2=pa.table([...pa.array([2,4]),...pa.array(["Parrot","Dog"])...],names=['n_legs','animals'])>>>pa.concat_tables([t1,t2])pyarrow.Tablen_legs: int64animals: string----n_legs: [[2,4,5,100],[2,4]]animals: [["Flamingo","Horse","Brittle stars","Centipede"],["Parrot","Dog"]]