V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
bingowrt
V2EX  ›  问与答

pandas 是否可以计算一句话中特定单词的出现频率

  •  
  •   bingowrt · Feb 18, 2019 · 1258 views
    This topic created in 2636 days ago, the information mentioned may be changed or developed.
    假设我们有 df.introduction[0]='this is a good day, I love it'
    那么 是否有办法可以让 df['I_counter'] = df.introduction.apply(lambda x: ??? )
    的运行结果为 df['I_counter'] = 1 也就是计算了 I 这个单词的出现频率 (???部分为需要补全的内容)

    之所以不用.split ()然后循环比较再一行一行添加,是因为计算效率太低( 50000 多行数据半天也搞不好)

    谢谢大家
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4766 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 64ms · UTC 09:53 · PVG 17:53 · LAX 02:53 · JFK 05:53
    ♥ Do have faith in what you're doing.