From 7f43baa7b24ec36b65426428209901c7599c41ef Mon Sep 17 00:00:00 2001 From: Yunika Bajracharya <60802409+Yunika-Bajracharya@users.noreply.github.com> Date: Mon, 19 Sep 2022 14:25:42 +0545 Subject: DOC: Add examples for join and index (#22299) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- numpy/core/defchararray.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'numpy/core/defchararray.py') 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='>> np.char.join(['-', '.'], ['ghc', 'osd']) + array(['g-h-c', 'o.s.d'], dtype='