dtoolkit.accessor.dataframe.to_zh#

dtoolkit.accessor.dataframe.to_zh(df: DataFrame, /, column: Hashable, *, locale: Literal['zh-hans', 'zh-hant', 'zh-cn', 'zh-sg', 'zh-tw', 'zh-hk', 'zh-my', 'zh-mo'] = 'zh-cn', dictionary: dict = None) DataFrame[source]#

Simple conversion and localization between simplified and traditional Chinese.

Parameters:
columnHashable

The column to convert.

locale{“zh-hans”, “zh-hant”, “zh-cn”, “zh-sg”, “zh-tw”, “zh-hk”, “zh-my”, “zh-mo”}, default “zh-cn”

Locale to convert to.

dictionarydict, default None

A dictionary which updates the conversion table, eg. {'from1': 'to1', 'from2': 'to2'}

Returns:
Series(string)
Raises:
ModuleNotFoundError

If don’t have module named ‘zhconv’.

TypeError

If s is not string dtype.

Examples

>>> import dtoolkit
>>> import pandas as pd
>>> df = pd.DataFrame({'zh': ['漢', '字']})
>>> df
   zh
0  漢
1  字
>>> df.to_zh('zh')
   zh
0  汉
1  字