Return an array with the elements of `a` left-justified in a string of length `width`. Calls `str.ljust` element-wise. Parameters ---------- a : array_like of str or unicode width : int The length of the resulting strings fillchar : str or unicode, optiona
(a, width, fillchar=' ')
| 1066 | |
| 1067 | @array_function_dispatch(_just_dispatcher) |
| 1068 | def ljust(a, width, fillchar=' '): |
| 1069 | """ |
| 1070 | Return an array with the elements of `a` left-justified in a |
| 1071 | string of length `width`. |
| 1072 | |
| 1073 | Calls `str.ljust` element-wise. |
| 1074 | |
| 1075 | Parameters |
| 1076 | ---------- |
| 1077 | a : array_like of str or unicode |
| 1078 | |
| 1079 | width : int |
| 1080 | The length of the resulting strings |
| 1081 | fillchar : str or unicode, optional |
| 1082 | The character to use for padding |
| 1083 | |
| 1084 | Returns |
| 1085 | ------- |
| 1086 | out : ndarray |
| 1087 | Output array of str or unicode, depending on input type |
| 1088 | |
| 1089 | See Also |
| 1090 | -------- |
| 1091 | str.ljust |
| 1092 | |
| 1093 | """ |
| 1094 | a_arr = numpy.asarray(a) |
| 1095 | width_arr = numpy.asarray(width) |
| 1096 | size = int(numpy.max(width_arr.flat)) |
| 1097 | if numpy.issubdtype(a_arr.dtype, numpy.bytes_): |
| 1098 | fillchar = asbytes(fillchar) |
| 1099 | return _vec_string( |
| 1100 | a_arr, type(a_arr.dtype)(size), 'ljust', (width_arr, fillchar)) |
| 1101 | |
| 1102 | |
| 1103 | @array_function_dispatch(_unary_op_dispatcher) |
no test coverage detected