pandas.Series.str.encode

pandas 3.1.1 · Series and accessors · method

Encode strings as bytes using a selected character encoding.

Call syntax

Series.str.encode(encoding, errors='strict')

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
encoding Required
Positional or keyword
str

Name a text encoding such as "utf-8".

errors Optional
Positional or keyword
Default 'strict'
str

Choose how to handle invalid input or failed operations. The available options depend on the API.

Returns

Series/Index of objects