From 60f1d14f155b5409113060287a089f44a10ba353 Mon Sep 17 00:00:00 2001 From: Satish Mishra Date: Sat, 2 Jul 2022 15:11:40 +0530 Subject: Add usage example to np.char.center docstring --- numpy/core/defchararray.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'numpy/core/defchararray.py') 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='>> np.char.center(c, width=9) + array([' a1b2 ', ' 1b2a ', ' b2a1 ', ' 2a1b '], dtype='>> np.char.center(c, width=9, fillchar='*') + array(['***a1b2**', '***1b2a**', '***b2a1**', '***2a1b**'], dtype='>> np.char.center(c, width=1) + array(['a', '1', 'b', '2'], dtype='