MCPcopy Create free account
hub / github.com/numpy/numpy / zfill

Function zfill

numpy/core/defchararray.py:1817–1844  ·  view source on GitHub ↗

Return the numeric string left-filled with zeros Calls `str.zfill` element-wise. Parameters ---------- a : array_like, {str, unicode} Input array. width : int Width of string to left-fill elements in `a`. Returns ------- out : ndarray, {str, un

(a, width)

Source from the content-addressed store, hash-verified

1815
1816@array_function_dispatch(_zfill_dispatcher)
1817def zfill(a, width):
1818 """
1819 Return the numeric string left-filled with zeros
1820
1821 Calls `str.zfill` element-wise.
1822
1823 Parameters
1824 ----------
1825 a : array_like, {str, unicode}
1826 Input array.
1827 width : int
1828 Width of string to left-fill elements in `a`.
1829
1830 Returns
1831 -------
1832 out : ndarray, {str, unicode}
1833 Output array of str or unicode, depending on input type
1834
1835 See Also
1836 --------
1837 str.zfill
1838
1839 """
1840 a_arr = numpy.asarray(a)
1841 width_arr = numpy.asarray(width)
1842 size = int(numpy.max(width_arr.flat))
1843 return _vec_string(
1844 a_arr, type(a_arr.dtype)(size), 'zfill', (width_arr,))
1845
1846
1847@array_function_dispatch(_unary_op_dispatcher)

Callers 1

zfillMethod · 0.85

Calls 2

_vec_stringFunction · 0.90
maxMethod · 0.45

Tested by

no test coverage detected