pandas.Series.str.decode#

Series.str.decode(encoding, errors='strict', dtype=None)[源代码]#

使用指定的编码解码 Series/Index 中的字符字符串。

等同于 python2 中的 str.decode() 和 python3 中的 bytes.decode()

Parameters:
encodingstr
errorsbool, default False

指定错误处理方案。可能的值是 bytes.decode() 所支持的值。

dtypestr 或 dtype,可选。

结果的 dtype。当不为 None 时,必须是字符串或 object dtypes。当为 None 时,结果的 dtype 由 pd.options.future.infer_string 决定。

在 2.3.0 版本加入.

Returns:
Series 或 Index

Examples

对于 Series:

>>> ser = pd.Series([b'cow', b'123', b'()'])
>>> ser.str.decode('ascii')
0   cow
1   123
2   ()
dtype: object