pandas 1.4.2

ParametersReturns
pad(self, width, side='left', fillchar=' ')

Parameters

width : int

Minimum width of resulting string; additional characters will be filled with character defined in :None:None:`fillchar`.

side : {'left', 'right', 'both'}, default 'left'

Side from which to fill resulting string.

fillchar : str, default ' '

Additional character for filling, default is whitespace.

Returns

Series or Index of object

Returns Series or Index with minimum number of char in object.

Pad strings in the Series/Index up to width.

See Also

Series.str.center

Fills both sides of strings with an arbitrary character. Equivalent to Series.str.pad(side='both') .

Series.str.ljust

Fills the right side of strings with an arbitrary character. Equivalent to Series.str.pad(side='right') .

Series.str.rjust

Fills the left side of strings with an arbitrary character. Equivalent to Series.str.pad(side='left') .

Series.str.zfill

Pad strings in the Series/Index by prepending '0' character. Equivalent to Series.str.pad(side='left', fillchar='0') .

Examples

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series(["caribou", "tiger"])
... s 0 caribou 1 tiger dtype: object
This example is valid syntax, but we were not able to check execution
>>> s.str.pad(width=10)
0       caribou
1         tiger
dtype: object
This example is valid syntax, but we were not able to check execution
>>> s.str.pad(width=10, side='right', fillchar='-')
0    caribou---
1    tiger-----
dtype: object
This example is valid syntax, but we were not able to check execution
>>> s.str.pad(width=10, side='both', fillchar='-')
0    -caribou--
1    --tiger---
dtype: object
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/strings/accessor.py#1511
type: <class 'function'>
Commit: