Return an array with the elements of `a` right-justified in a string of length `width`. Calls `str.rjust` element-wise. Parameters ---------- a : array_like of str or unicode width : int The length of the resulting strings fillchar : str or unicode, option
(a, width, fillchar=' ')
| 1344 | |
| 1345 | @array_function_dispatch(_just_dispatcher) |
| 1346 | def rjust(a, width, fillchar=' '): |
| 1347 | """ |
| 1348 | Return an array with the elements of `a` right-justified in a |
| 1349 | string of length `width`. |
| 1350 | |
| 1351 | Calls `str.rjust` element-wise. |
| 1352 | |
| 1353 | Parameters |
| 1354 | ---------- |
| 1355 | a : array_like of str or unicode |
| 1356 | |
| 1357 | width : int |
| 1358 | The length of the resulting strings |
| 1359 | fillchar : str or unicode, optional |
| 1360 | The character to use for padding |
| 1361 | |
| 1362 | Returns |
| 1363 | ------- |
| 1364 | out : ndarray |
| 1365 | Output array of str or unicode, depending on input type |
| 1366 | |
| 1367 | See Also |
| 1368 | -------- |
| 1369 | str.rjust |
| 1370 | |
| 1371 | """ |
| 1372 | a_arr = numpy.asarray(a) |
| 1373 | width_arr = numpy.asarray(width) |
| 1374 | size = int(numpy.max(width_arr.flat)) |
| 1375 | if numpy.issubdtype(a_arr.dtype, numpy.bytes_): |
| 1376 | fillchar = asbytes(fillchar) |
| 1377 | return _vec_string( |
| 1378 | a_arr, type(a_arr.dtype)(size), 'rjust', (width_arr, fillchar)) |
| 1379 | |
| 1380 | |
| 1381 | @array_function_dispatch(_partition_dispatcher) |
no test coverage detected