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