Is there a way to convert number words to Integers?

前端 未结 16 2009
北恋
北恋 2020-11-22 06:14

I need to convert one into 1, two into 2 and so on.

Is there a way to do this with a library or a class or anythi

16条回答
  •  难免孤独
    2020-11-22 06:42

    This code works for a series data:

    import pandas as pd
    mylist = pd.Series(['one','two','three'])
    mylist1 = []
    for x in range(len(mylist)):
        mylist1.append(w2n.word_to_num(mylist[x]))
    print(mylist1)
    

提交回复
热议问题