def str_encode(arr, encoding, errors="<STR_LIT:strict>"):
if encoding in _cpython_optimized_encoders:<EOL><INDENT>f = lambda x: x.encode(encoding, errors)<EOL><DEDENT>else:<EOL><INDENT>encoder = codecs.getencoder(encoding)<EOL>f = lambda x: encoder(x, errors)[<NUM_LIT:0>]<EOL><DEDENT>return _na_map(f, arr)<EOL>
Encode character string in the Series/Index using indicated encoding.
Equivalent to :meth:`str.encode`.

Parameters
----------
encoding : str
errors : str, optional

Returns
-------
encoded : Series/Index of objects