我有一个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
提交
取消