pandas.Series.str.normalize#

Series.str.normalize(form)[源代码]#

返回 Series/Index 中字符串的 Unicode 正规形式。

有关表单的更多信息,请参见 unicodedata.normalize()

参数:
表单{‘NFC’, ‘NFKC’, ‘NFD’, ‘NFKD’}

Unicode 形式。

返回:
对象的系列/索引

A Series or Index of strings in the same Unicode form specified by form. The returned object retains the same type as the input (Series or Index), and contains the normalized strings.

参见

Series.str.upper

Convert all characters in each string to uppercase.

Series.str.lower

Convert all characters in each string to lowercase.

Series.str.title

Convert each string to title case (capitalizing the first letter of each word).

Series.str.strip

Remove leading and trailing whitespace from each string.

Series.str.replace

Replace occurrences of a substring with another substring in each string.

例子

>>> ser = pd.Series(["ñ"])
>>> ser.str.normalize("NFC") == ser.str.normalize("NFD")
0   False
dtype: bool