前処理に使えそうなライブラリ
URL
概要(or Nothing)
サンプルコード(Need)
日本語関連
code:sample.py
import neologdn
neologdn.normalize("ハンカクカナ")
# => 'ハンカクカナ'
neologdn.normalize("全角記号!?@#")
# => '全角記号!?@#'
convert 半角 to 全角
code:sample.py
>> import mojimoji
>> print mojimoji.zen_to_han(u'アイウabc012')
アイウabc012
convert 和暦(str) to 西暦(int)
code:sample.py
from jeraconv import jeraconv
# Create J2W class instance
j2w = jeraconv.J2W()
# ex.1 : General usage
print(j2w.convert('文治6年'))
# result (int) 1190
# ex.2 : Full-width numbers are also available
print(j2w.convert('平成31年'))
# result (int) 2019
# ex.3 : It is also possible to write "1年" as "元年"
print(j2w.convert('令和元年'))
# result (int) 2019
convert 漢数字(str) to 数字(int)
code:sample.py
from kanjize import int2kanji, kanji2int, Number
print(int2kanji(58076099))
# 五千八百七万六千九十九
print(kanji2int("五千八百七万六千九十九"))
# 58076099
convert 和暦(str) to datetime
janera.strptime の formatが作りこんであってよい
code:sample.py
from japanera import Japanera
janera = Japanera()
janera.strptime('令和元年05月01日', "%-E%-O年%m月%d日")
janera.strptime('令和01年05月01日', "%-E%-o年%m月%d日")
import pandas as pd
# get part of it from list
pd.to_datetime(sample'date'.map(lambda x: janera.strptime(x, "%-E%-o年%m月%d日")).str0) # 0 2019-05-01
# 1 2020-05-01
# Name: date, dtype: datetime64ns