diff options
| -rw-r--r-- | numpy/core/defchararray.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py index 3521e778e..fdda44e56 100644 --- a/numpy/core/defchararray.py +++ b/numpy/core/defchararray.py @@ -445,6 +445,22 @@ def center(a, width, fillchar=' '): See Also -------- str.center + + Notes + ----- + This function is intended to work with arrays of strings. The + fill character is not applied to numeric types. + + Examples + -------- + >>> c = np.array(['a1b2','1b2a','b2a1','2a1b']); c + array(['a1b2', '1b2a', 'b2a1', '2a1b'], dtype='<U4') + >>> np.char.center(c, width=9) + array([' a1b2 ', ' 1b2a ', ' b2a1 ', ' 2a1b '], dtype='<U9') + >>> np.char.center(c, width=9, fillchar='*') + array(['***a1b2**', '***1b2a**', '***b2a1**', '***2a1b**'], dtype='<U9') + >>> np.char.center(c, width=1) + array(['a', '1', 'b', '2'], dtype='<U1') """ a_arr = numpy.asarray(a) |
