Return a copy of `a` with only the first character of each element capitalized. Calls `str.capitalize` element-wise. For 8-bit strings, this method is locale-dependent. Parameters ---------- a : array_like of str or unicode Input array of strings to capitalize
(a)
| 421 | |
| 422 | @array_function_dispatch(_unary_op_dispatcher) |
| 423 | def capitalize(a): |
| 424 | """ |
| 425 | Return a copy of `a` with only the first character of each element |
| 426 | capitalized. |
| 427 | |
| 428 | Calls `str.capitalize` element-wise. |
| 429 | |
| 430 | For 8-bit strings, this method is locale-dependent. |
| 431 | |
| 432 | Parameters |
| 433 | ---------- |
| 434 | a : array_like of str or unicode |
| 435 | Input array of strings to capitalize. |
| 436 | |
| 437 | Returns |
| 438 | ------- |
| 439 | out : ndarray |
| 440 | Output array of str or unicode, depending on input |
| 441 | types |
| 442 | |
| 443 | See Also |
| 444 | -------- |
| 445 | str.capitalize |
| 446 | |
| 447 | Examples |
| 448 | -------- |
| 449 | >>> c = np.array(['a1b2','1b2a','b2a1','2a1b'],'S4'); c |
| 450 | array(['a1b2', '1b2a', 'b2a1', '2a1b'], |
| 451 | dtype='|S4') |
| 452 | >>> np.char.capitalize(c) |
| 453 | array(['A1b2', '1b2a', 'B2a1', '2a1b'], |
| 454 | dtype='|S4') |
| 455 | |
| 456 | """ |
| 457 | a_arr = numpy.asarray(a) |
| 458 | return _vec_string(a_arr, a_arr.dtype, 'capitalize') |
| 459 | |
| 460 | |
| 461 | def _center_dispatcher(a, width, fillchar=None): |
no test coverage detected