bundles / numpy latest / numpy / strings / ljust
_ArrayFunctionDispatcher
numpy.strings:ljust
source: build-install/usr/lib/python3.14/site-packages/numpy/_core/strings.py :760
Signature
def ljust ( a , width , fillchar = ) Summary
Return an array with the elements of a left-justified in a string of length width.
Parameters
a: array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtypewidth: array_like, with any integer dtypeThe length of the resulting strings, unless
width < str_len(a).fillchar: array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtypeOptional character to use for padding (default is space).
Returns
out: ndarrayOutput array of
StringDType,bytes_orstr_dtype, depending on input types
Notes
While it is possible for a and fillchar to have different dtypes, passing a non-ASCII character in fillchar when a is of dtype "S" is not allowed, and a ValueError is raised.
Examples
import numpy as np c = np.array(['aAaAaA', ' aA ', 'abBABba']) np.strings.ljust(c, width=3) np.strings.ljust(c, width=9)✓
See also
- str.ljust
Aliases
-
numpy.char.ljust