From 9b94c6fed78d8aaf358f7552c17754037b3bf320 Mon Sep 17 00:00:00 2001 From: Simran Makandar <70259514+simranmakandar@users.noreply.github.com> Date: Fri, 30 Sep 2022 15:28:27 -0500 Subject: DOC: add examples to numpy.char.replace (#22308) Co-authored-by: Tyler Reddy Co-authored-by: Sebastian Berg Co-authored-by: Ross Barnowski --- numpy/core/defchararray.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'numpy/core/defchararray.py') 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='>> 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='