@@ -197,7 +197,19 @@ def mod(a, values):
197
197
out : ndarray
198
198
Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
199
199
depending on input types
200
-
200
+
201
+ Examples
202
+ --------
203
+ >>> import numpy as np
204
+ >>> a = np.array(["NumPy is a %s library"])
205
+ >>> np.strings.mod(a, values=["Python"])
206
+ array(['NumPy is a Python library'], dtype='<U25')
207
+
208
+ >>> a = np.array([b'%d bytes', b'%d bits'])
209
+ >>> values = np.array([8, 64])
210
+ >>> np.strings.mod(a, values)
211
+ array([b'8 bytes', b'64 bits'], dtype='|S7')
212
+
201
213
"""
202
214
return _to_bytes_or_str_array (
203
215
_vec_string (a , np .object_ , '__mod__' , (values ,)), a )
@@ -265,6 +277,18 @@ def rfind(a, sub, start=0, end=None):
265
277
--------
266
278
str.rfind
267
279
280
+ Examples
281
+ --------
282
+ >>> import numpy as np
283
+ >>> a = np.array(["Computer Science"])
284
+ >>> np.strings.rfind(a, "Science", start=0, end=None)
285
+ array([9])
286
+ >>> np.strings.rfind(a, "Science", start=0, end=8)
287
+ array([-1])
288
+ >>> b = np.array(["Computer Science", "Science"])
289
+ >>> np.strings.rfind(b, "Science", start=0, end=None)
290
+ array([9, 0])
291
+
268
292
"""
269
293
end = end if end is not None else MAX
270
294
return _rfind_ufunc (a , sub , start , end )
@@ -404,6 +428,17 @@ def startswith(a, prefix, start=0, end=None):
404
428
--------
405
429
str.startswith
406
430
431
+ Examples
432
+ --------
433
+ >>> import numpy as np
434
+ >>> s = np.array(['foo', 'bar'])
435
+ >>> s
436
+ array(['foo', 'bar'], dtype='<U3')
437
+ >>> np.strings.startswith(s, 'fo')
438
+ array([True, False])
439
+ >>> np.strings.startswith(s, 'o', start=1, end=2)
440
+ array([True, False])
441
+
407
442
"""
408
443
end = end if end is not None else MAX
409
444
return _startswith_ufunc (a , prefix , start , end )
0 commit comments