从pandas数据框中删除行,该行的列包含字符串,且单词的长度大于一定长度

时间:2020-07-15 12:44:09

标签: python pandas string dataframe max

我有这个数据框

qid question_stemmed    target  question_length total_words
443216  56da6b6875d686b48fde    mathfracint1x53x5 tantanboxedint1x01x2 sumvarp...   1   589 40
163583  1ffca149bd0a19cd714c    mathoverbracesumvartheta8infty vecfracsumkappa...   1   498 31
522266  663c7523d48f5ee66a3e    star trek 2013 ?make warping look quite bit li...   0   449 66
341312  42dc38e62f0bdebfa6b6    answer mathfrac4222262mid 5501int846fracomega2...   0   334 11
149952  1d53c9c017999b4f77e2    8430397824532987451912384179815150754023741609...   0   241 3

我希望删除上面的行,其中question_stemmed列在这种情况下包含多个单词的字符串,其中单词长度超过某个字符长度(例如:15个字符)

我如何实现上述目标? 我找到了另一个stackoverflow链接-Remove the rows from pandas dataframe, that has sentences longer than certain word length

但是实际上删除了行数大于一定限制的行,但是我的目标是不同的。感谢任何帮助!

0 个答案:

没有答案