numpy.strings.ljust
- strings.ljust(a, width, fillchar=' ')[source]
-
Return an array with the elements of
aleft-justified in a string of lengthwidth.Calls
str.ljustelement-wise.- Parameters:
-
-
aarray-like, with
StringDType,bytes_, orstr_dtype - widtharray_like, with any integer dtype
-
The length of the resulting strings, unless
width < str_len(a). -
fillchararray-like, with
StringDType,bytes_, orstr_dtype -
Optional character to use for padding (default is space).
-
aarray-like, with
- Returns:
-
- outndarray
-
Output array of
StringDType,bytes_orstr_dtype, depending on input types
See also
Examples
>>> c = np.array(['aAaAaA', ' aA ', 'abBABba']) >>> np.strings.ljust(c, width=3) array(['aAa', ' a', 'abB'], dtype='<U3')
© 2005–2024 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/2.0/reference/generated/numpy.strings.ljust.html