numpy.char.rjust#
- char.rjust(a, width, fillchar=' ')[source]#
Return an array with the elements of a right-justified in a string of length width.
Calls
str.rjust
element-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 padding character to use (default is space).
- aarray-like, with
- Returns:
- outndarray
Output array of
StringDType
,bytes_
orstr_
dtype, depending on input types
See also
Examples
>>> a = np.array(['aAaAaA', ' aA ', 'abBABba']) >>> np.strings.rjust(a, width=3) array(['aAa', ' a', 'abB'], dtype='<U3')