MCPcopy Create free account
hub / github.com/numpy/numpy / encode

Function encode

numpy/core/defchararray.py:619–651  ·  view source on GitHub ↗

Calls `str.encode` element-wise. The set of available codecs comes from the Python standard library, and may be extended at runtime. For more information, see the codecs module. Parameters ---------- a : array_like of str or unicode encoding : str, optional

(a, encoding=None, errors=None)

Source from the content-addressed store, hash-verified

617
618@array_function_dispatch(_code_dispatcher)
619def encode(a, encoding=None, errors=None):
620 """
621 Calls `str.encode` element-wise.
622
623 The set of available codecs comes from the Python standard library,
624 and may be extended at runtime. For more information, see the codecs
625 module.
626
627 Parameters
628 ----------
629 a : array_like of str or unicode
630
631 encoding : str, optional
632 The name of an encoding
633
634 errors : str, optional
635 Specifies how to handle encoding errors
636
637 Returns
638 -------
639 out : ndarray
640
641 See Also
642 --------
643 str.encode
644
645 Notes
646 -----
647 The type of the result will depend on the encoding specified.
648
649 """
650 return _to_bytes_or_str_array(
651 _vec_string(a, object_, 'encode', _clean_args(encoding, errors)))
652
653
654def _endswith_dispatcher(a, suffix, start=None, end=None):

Callers 1

encodeMethod · 0.85

Calls 3

_vec_stringFunction · 0.90
_to_bytes_or_str_arrayFunction · 0.85
_clean_argsFunction · 0.85

Tested by

no test coverage detected