numpy.core.defchararray.ljust (arr, width, fillchar = & # 39; & # 39;)
— this is another function for doing string operations in numpy. Returns an array with left-aligned arr elements in a length-width string. It fills the remaining space of each element in the array with the fillchr
parameter fillchr
. If fillchr
is not passed, the remaining spaces are filled 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: Output array of str or unicode, depending on input type.
Code # 1:
|
Output :
Input array: [’Numpy’’ Python’ ’Pandas’] Output left justified array: [’Numpy’ ’Python’ ’Pandas’]
Code # 2:
|
Exit:
Input array: [’Numpy’’ Python’ ’Pandas’] Output left justified array: [’ Numpy *** ’’ Python ** ’’ Pandas ** ’]
Code # 3:
|
Output:
Input array: [’1’’ 11’ ’111’] Ou tput left justified array: [’1 ----’ ’11 ---’ ’111 -’]