diff options
author | Yunika Bajracharya <60802409+Yunika-Bajracharya@users.noreply.github.com> | 2022-09-19 14:25:42 +0545 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-19 10:40:42 +0200 |
commit | 7f43baa7b24ec36b65426428209901c7599c41ef (patch) | |
tree | 89f75ddf92b3edf8b2f47bc91928d93a393f0119 /numpy/core/defchararray.py | |
parent | 0b7b940ecb436427289093b3becb51f935eb05df (diff) | |
download | numpy-7f43baa7b24ec36b65426428209901c7599c41ef.tar.gz |
DOC: Add examples for join and index (#22299)
Add examples for join and index for issue #22267
* DOC: add join, index examples
* DOC: update join in np.char
Co-authored-by: Brigitta Sipőcz <b.sipocz@gmail.com>
Diffstat (limited to 'numpy/core/defchararray.py')
-rw-r--r-- | numpy/core/defchararray.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py index 063b0c724..56f93af31 100644 --- a/numpy/core/defchararray.py +++ b/numpy/core/defchararray.py @@ -779,6 +779,12 @@ def index(a, sub, start=0, end=None): -------- find, str.find + Examples + -------- + >>> a = np.array(["Computer Science"]) + >>> np.char.index(a, "Science", start=0, end=None) + array([9]) + """ return _vec_string( a, int_, 'index', [sub, start] + _clean_args(end)) @@ -1001,6 +1007,15 @@ def join(sep, seq): See Also -------- str.join + + Examples + -------- + >>> np.char.join('-', 'osd') + array('o-s-d', dtype='<U5') + + >>> np.char.join(['-', '.'], ['ghc', 'osd']) + array(['g-h-c', 'o.s.d'], dtype='<U5') + """ return _to_string_or_unicode_array( _vec_string(sep, object_, 'join', (seq,))) |