Method: Polars::Functions#zeros

Defined in:
lib/polars/functions/repeat.rb

#zeros(n, dtype: Float64, eager: false) ⇒ Object

Construct a column of length n filled with zeros.

This is syntactic sugar for the repeat function.

Examples:

Polars.zeros(3, dtype: Polars::Int8, eager: true)
# =>
# shape: (3,)
# Series: 'zeros' [i8]
# [
#         0
#         0
#         0
# ]

Parameters:

  • n (Integer)

    Length of the resulting column.

  • dtype (Object) (defaults to: Float64)

    Data type of the resulting column. Defaults to Float64.

  • eager (Boolean) (defaults to: false)

    Evaluate immediately and return a Series. If set to false, return an expression instead.

Returns:



109
110
111
112
113
114
115
116
# File 'lib/polars/functions/repeat.rb', line 109

def zeros(n, dtype: Float64, eager: false)
  if (zero = _one_or_zero_by_dtype(0, dtype)).nil?
    msg = "invalid dtype for `zeros`; found #{dtype}"
    raise TypeError, msg
  end

  repeat(zero, n, dtype: dtype, eager: eager).alias("zeros")
end