我有一個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)
添加回答
舉報
0/150
提交
取消