开发者社区> 问答> 正文

应用NLP标记

如何在单列上应用标记化一次?我有两列我想为每列的单列应用标记化功能
本问题及下方已被采纳的回答均来自云栖社区【Python技术进阶大群】。https://yq.aliyun.com/articles/690084 点击链接欢迎加入社区大社群。

展开
收起
一码平川MACHEL 2019-02-28 14:58:30 1898 0
1 条回答
写回答
取消 提交回答
  • 您可以使用pandas apply函数在列的每一行上应用标记化

    import pandas as pd
    df = pd.DataFrame()
    df['col1'] = ['ow to apply tokenization at a ','single column once ? I have two columns I w']
    df['col2'] = ['unction for every row of single',' columns, can you please suggest']

                 col1                        col2

    0 ow to apply tokenization at a unction for every row of single
    1 single column once ? I have two columns I w columns, can you please suggest

    import nltk
    df['col1'].apply(nltk.tokenize.word_tokenize)
    日期:

    0 [ow, to, apply, tokenization, at, a]
    1 [single, column, once, ?, I, have, two, column...
    Name: col1, dtype: object

    2019-07-17 23:29:48
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
自然语言处理得十个发展趋势 立即下载
自然语言处理的十个发展趋势 立即下载
深度学习与自然语言处理 立即下载