Return an array with the elements of a left-justified in a string of length width.
StringDType, bytes_, or str_ dtype
The length of the resulting strings, unless width < str_len(a).
StringDType, bytes_, or str_ dtype
Optional character to use for padding (default is space).
Output array of StringDType, bytes_ or str_ dtype, depending on input types
See also
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.
>>> import numpy as np >>> c = np.array(['aAaAaA', ' aA ', 'abBABba']) >>> np.strings.ljust(c, width=3) array(['aAaAaA', ' aA ', 'abBABba'], dtype='<U7') >>> np.strings.ljust(c, width=9) array(['aAaAaA ', ' aA ', 'abBABba '], dtype='<U9')
Ā© 2005ā2024 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/2.4/reference/generated/numpy.strings.ljust.html