pyarrow.repeat#

pyarrow.repeat(value,size,MemoryPoolmemory_pool=None)#

Create an Array instance whose slots are the given scalar.

Parameters:
valueScalar-like object

Either a pyarrow.Scalar or any python object coercible to a Scalar.

sizeint

Number of times to repeat the scalar in the output Array.

memory_poolMemoryPool, defaultNone

Arrow MemoryPool to use for allocations. Uses the default memorypool if not passed.

Returns:
arrArray

Examples

>>>importpyarrowaspa>>>pa.repeat(10,3)<pyarrow.lib.Int64Array object at ...>[  10,  10,  10]
>>>pa.repeat([1,2],2)<pyarrow.lib.ListArray object at ...>[  [    1,    2  ],  [    1,    2  ]]
>>>pa.repeat("string",3)<pyarrow.lib.StringArray object at ...>[  "string",  "string",  "string"]
>>>pa.repeat(pa.scalar({'a':1,'b':[1,2]}),2)<pyarrow.lib.StructArray object at ...>-- is_valid: all not null-- child 0 type: int64  [    1,    1  ]-- child 1 type: list<item: int64>  [    [      1,      2    ],    [      1,      2    ]  ]