Skip to content

Commit 78a9810

Browse files
DOC: Add examples for np.strings.mod()
1 parent fc84300 commit 78a9810

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

numpy/_core/strings.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,19 @@ def mod(a, values):
197197
out : ndarray
198198
Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
199199
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+
201213
"""
202214
return _to_bytes_or_str_array(
203215
_vec_string(a, np.object_, '__mod__', (values,)), a)

0 commit comments

Comments
 (0)