MCPcopy Index your code
hub / github.com/numpy/numpy / capitalize

Function capitalize

numpy/_core/strings.py:1203–1239  ·  view source on GitHub ↗

Return a copy of ``a`` with only the first character of each element capitalized. Calls :meth:`str.capitalize` element-wise. For byte strings, this method is locale-dependent. Parameters ---------- a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype

(a)

Source from the content-addressed store, hash-verified

1201@set_module("numpy.strings")
1202@array_function_dispatch(_unary_op_dispatcher)
1203def capitalize(a):
1204 """
1205 Return a copy of ``a`` with only the first character of each element
1206 capitalized.
1207
1208 Calls :meth:`str.capitalize` element-wise.
1209
1210 For byte strings, this method is locale-dependent.
1211
1212 Parameters
1213 ----------
1214 a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
1215 Input array of strings to capitalize.
1216
1217 Returns
1218 -------
1219 out : ndarray
1220 Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
1221 depending on input types
1222
1223 See Also
1224 --------
1225 str.capitalize
1226
1227 Examples
1228 --------
1229 >>> import numpy as np
1230 >>> c = np.array(['a1b2','1b2a','b2a1','2a1b'],'S4'); c
1231 array(['a1b2', '1b2a', 'b2a1', '2a1b'],
1232 dtype='|S4')
1233 >>> np.strings.capitalize(c)
1234 array(['A1b2', '1b2a', 'B2a1', '2a1b'],
1235 dtype='|S4')
1236
1237 """
1238 a_arr = np.asarray(a)
1239 return _vec_string(a_arr, a_arr.dtype, 'capitalize')
1240
1241
1242@set_module("numpy.strings")

Callers 1

capitalizeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…