summaryrefslogtreecommitdiff
path: root/numpy/core/defchararray.py
diff options
context:
space:
mode:
authorDigya053 <digyaacharyaa@gmail.com>2022-09-19 14:53:02 -0500
committerGitHub <noreply@github.com>2022-09-19 12:53:02 -0700
commit65eb581a3bd4b5e0ee390606e20dc4b6f8597b34 (patch)
tree522d51d8db8db2db1fd25ad984f78a45d77e62b2 /numpy/core/defchararray.py
parent293dc0e242be473216fcceec421d7aceba4e285e (diff)
downloadnumpy-65eb581a3bd4b5e0ee390606e20dc4b6f8597b34.tar.gz
DOC: Add examples for isdigit and str_len (#22291)
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
Diffstat (limited to 'numpy/core/defchararray.py')
-rw-r--r--numpy/core/defchararray.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py
index 0da1a5639..2ccc30dd7 100644
--- a/numpy/core/defchararray.py
+++ b/numpy/core/defchararray.py
@@ -275,6 +275,18 @@ def str_len(a):
See Also
--------
builtins.len
+
+ Examples
+ --------
+ >>> a = np.array(['Grace Hopper Conference', 'Open Source Day'])
+ >>> np.char.str_len(a)
+ array([23, 15])
+ >>> a = np.array([u'\u0420', u'\u043e'])
+ >>> np.char.str_len(a)
+ array([1, 1])
+ >>> a = np.array([['hello', 'world'], [u'\u0420', u'\u043e']])
+ >>> np.char.str_len(a)
+ array([[5, 5], [1, 1]])
"""
# Note: __len__, etc. currently return ints, which are not C-integers.
# Generally intp would be expected for lengths, although int is sufficient
@@ -864,6 +876,15 @@ def isdigit(a):
See Also
--------
str.isdigit
+
+ Examples
+ --------
+ >>> a = np.array(['a', 'b', '0'])
+ >>> np.char.isdigit(a)
+ array([False, False, True])
+ >>> a = np.array([['a', 'b', '0'], ['c', '1', '2']])
+ >>> np.char.isdigit(a)
+ array([[False, False, True], [False, True, True]])
"""
return _vec_string(a, bool_, 'isdigit')