summaryrefslogtreecommitdiff
path: root/numpy/core/defchararray.py
diff options
context:
space:
mode:
authorSatish Mishra <zicsxone@gmail.com>2022-07-02 15:11:40 +0530
committerSatish Mishra <zicsxone@gmail.com>2022-07-02 15:11:40 +0530
commit60f1d14f155b5409113060287a089f44a10ba353 (patch)
tree7161cbd501a280ed7880de6482bd5dd9916d0e2c /numpy/core/defchararray.py
parent860a12ede7a4521debc16ef8c3a8b3d182b65c7a (diff)
downloadnumpy-60f1d14f155b5409113060287a089f44a10ba353.tar.gz
Add usage example to np.char.center docstring
Diffstat (limited to 'numpy/core/defchararray.py')
-rw-r--r--numpy/core/defchararray.py16
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)