diff options
author | Simran Makandar <70259514+simranmakandar@users.noreply.github.com> | 2022-09-30 15:28:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-30 13:28:27 -0700 |
commit | 9b94c6fed78d8aaf358f7552c17754037b3bf320 (patch) | |
tree | 96c9e274a4fd0294854299f059d117bed173c29c /numpy/core/defchararray.py | |
parent | 17051caef30ad3b99291077c95f5ca9e55f0e082 (diff) | |
download | numpy-9b94c6fed78d8aaf358f7552c17754037b3bf320.tar.gz |
DOC: add examples to numpy.char.replace (#22308)
Co-authored-by: Tyler Reddy <tyler.je.reddy@gmail.com>
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Diffstat (limited to 'numpy/core/defchararray.py')
-rw-r--r-- | numpy/core/defchararray.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py index 0a4b091a8..6750e497a 100644 --- a/numpy/core/defchararray.py +++ b/numpy/core/defchararray.py @@ -1250,7 +1250,16 @@ def replace(a, old, new, count=None): See Also -------- str.replace + + Examples + -------- + >>> a = np.array(["That is a mango", "Monkeys eat mangos"]) + >>> np.char.replace(a, 'mango', 'banana') + array(['That is a banana', 'Monkeys eat bananas'], dtype='<U19') + >>> a = np.array(["The dish is fresh", "This is it"]) + >>> np.char.replace(a, 'is', 'was') + array(['The dwash was fresh', 'Thwas was it'], dtype='<U19') """ return _to_string_or_unicode_array( _vec_string( |