polars.ones#

polars.ones(n: int, dtype: Optional[Union[Type[DataType], DataType]] = None) Series[source]#

Return a new Series of given length and type, filled with ones.

Parameters:
n

Number of elements in the Series

dtype

DataType of the elements, defaults to polars.Float64

Notes

In the lazy API you should probably not use this, but use lit(1) instead.

Examples

>>> pl.ones(5, pl.Int64)
shape: (5,)
Series: '' [i64]
[
    1
    1
    1
    1
    1
]