Method: Polars::StringNameSpace#zfill

Defined in:
lib/polars/string_name_space.rb

#zfill(length) ⇒ Series

Fills the string with zeroes.

Return a copy of the string left filled with ASCII '0' digits to make a string of length width.

A leading sign prefix ('+'/'-') is handled by inserting the padding after the sign character rather than before. The original string is returned if width is less than or equal to s.length.

Examples:

s = Polars::Series.new([-1, 123, 999999, nil])
s.cast(Polars::String).str.zfill(4)
# =>
# shape: (4,)
# Series: '' [str]
# [
#         "-001"
#         "0123"
#         "999999"
#         null
# ]

Parameters:

  • length (Integer)

    Fill the value up to this length.

Returns:



999
1000
1001
# File 'lib/polars/string_name_space.rb', line 999

def zfill(length)
  super
end