numpy.core.defchararray.rjust (arr, width, fillchar = & # 39; & # 39;)
— this is another function for doing string operations in numpy. It returns an array with arr elements right-aligned in a string of length width. It fills the remaining space of each array element with fillchr
the fillchr
fillchr
fillchr
is not passed, then it fills the remaining spaces with blank space.
Parameters:
arr: array_like of str or unicode.Input array.
width: The final width of the each string.
fillchar: The character to fill in remaining space.Returns: [ndarray] Output right justified array of str or unicode, depending on input type.
Code # 1:
|
Exit:
Input array: [’Numpy’’ Python’ ’Pandas’] Output right justified array: [’ Numpy’ ’Python’’ Pandas’]
Code # 2:
|
Exit :
Input array: [’Numpy’’ Python’ ’Pandas’] Output right justified array: [’ *** Numpy’ ’** Python’’ ** Pandas’]
Code # 3:
|
Output :
Input array: [’1’’ 11’ ’111’] Output right justified array: [’ ---- 1’ ’--- 11’ ’--111’]