pandas 1.4.2

NotesParametersReturns
zfill(self, width)

Strings in the Series/Index are padded with '0' characters on the left of the string to reach a total string length :None:None:`width`. Strings in the Series/Index with length greater or equal to :None:None:`width` are unchanged.

Notes

Differs from str.zfill which has special handling for '+'/'-' in the string.

Parameters

width : int

Minimum length of resulting string; strings with length less than :None:None:`width` be prepended with '0' characters.

Returns

Series/Index of objects.

Pad strings in the Series/Index by prepending '0' characters.

See Also

Series.str.center

Fills both sides of strings with an arbitrary character.

Series.str.ljust

Fills the right side of strings with an arbitrary character.

Series.str.pad

Fills the specified sides of strings with an arbitrary character.

Series.str.rjust

Fills the left side of strings with an arbitrary character.

Examples

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series(['-1', '1', '1000', 10, np.nan])
... s 0 -1 1 1 2 1000 3 10 4 NaN dtype: object

Note that 10 and NaN are not strings, therefore they are converted to NaN . The minus sign in '-1' is treated as a regular character and the zero is added to the left of it ( str.zfill would have moved it to the left). 1000 remains unchanged as it is longer than :None:None:`width`.

This example is valid syntax, but we were not able to check execution
>>> s.str.zfill(3)
0     0-1
1     001
2    1000
3     NaN
4     NaN
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#1614
type: <class 'function'>
Commit: