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

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

  •  
  •   bingowrt · Feb 18, 2019 · 1239 views
    This topic created in 2626 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   ·   2869 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 15:40 · PVG 23:40 · LAX 08:40 · JFK 11:40
    ♥ Do have faith in what you're doing.