Skip to content

featurebyte.ViewColumn.str.pad

pad(
width: int,
side: Literal["left", "right", "both"]="left",
fillchar: str=" "
) -> FrozenSeries

Description

Pads each string element up to the specified width.

Parameters

  • width: int
    Minimum width of resulting string. Additional characters will be filled with fillchar.

  • side: Literal["left", "right", "both"]
    default: "left"
    Padding direction.

  • fillchar: str
    default: " "
    Character used to pad.

Returns

  • FrozenSeries
    A new Column or Feature object.

Examples

Pad the Title column to 10 characters:

>>> view = catalog.get_view("GROCERYCUSTOMER")
>>> view["PostalCodePadded"] = view["PostalCode"].str.pad(10, fillchar="0")
>>> view.preview(5).filter(regex="PostalCode")
  PostalCode PostalCodePadded
0      52000       0000052000
1      68200       0000068200
2      12100       0000012100
3      97232       0000097232
4      63000       0000063000