numpy.strings.rjust#
- strings.rjust(a,width,fillchar='')[source]#
Return an array with the elements ofa right-justified in astring of lengthwidth.
- 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
Notes
While it is possible for
aandfillcharto have different dtypes,passing a non-ASCII character infillcharwhenais of dtype “S”is not allowed, and aValueErroris raised.Examples
>>>importnumpyasnp>>>a=np.array(['aAaAaA',' aA ','abBABba'])>>>np.strings.rjust(a,width=3)array(['aAaAaA', ' aA ', 'abBABba'], dtype='<U7')>>>np.strings.rjust(a,width=9)array([' aAaAaA', ' aA ', ' abBABba'], dtype='<U9')
On this page