亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

對每行數據幀中的搜索詞進行計數

對每行數據幀中的搜索詞進行計數

海綿寶寶撒 2022-09-20 17:20:29
我有一個python中的數據幀word    string                                               count    wordSummaryapple    One apple price is 40apple    one apple price is 50 and three apples price are 60 but apple....我想從字符串中計算確切的單詞,并在單詞之前和之后的5chars中計算5charsword    string                                                         count  wordSummary apple    One apple price is 40                                            1   Once apple priceapple    one apple price is 50 and three apples price are 60 but apple    2  one apple price我嘗試了以下部分,但顯示錯誤。df["count"] = df["string"].count(df["word"])
查看完整描述

1 回答

?
慕桂英4014372

TA貢獻1871條經驗 獲得超13個贊

嘗試申請:

df['count'] = df.apply(lambda row: row['string'].lower().split(' ').count(row['word'].lower()), axis=1)

共享


查看完整回答
反對 回復 2022-09-20
  • 1 回答
  • 0 關注
  • 81 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號