我有3个包含英语单词、名称和位置的数据框。对于每个数据帧,我尝试删除长度小于3的所有单词,并使用以下代码:
english_words=english_words[english_words[0].map(len) >= 3]
names=names[names[0].map(len) >= 3]
places=places[places[0].map(len) >=3]
所有数据帧只有一列。 我希望得到的新数据帧只包含长度大于或等于3的字,但我得到的错误如下:
TypeError Traceback (most recent call last)
<ipython-input-21-d16d0eaf3a11> in <module>
----> 1 english_words=english_words[[(len(x) > 5) for x in english_words[0]]]
2 names=names[names[0].map(len) >= 3]
3 places=places[places[0].map(len) >=3]
<ipython-input-21-d16d0eaf3a11> in <listcomp>(.0)
----> 1 english_words=english_words[[(len(x) > 5) for x in english_words[0]]]
2 names=names[names[0].map(len) >= 3]
3 places=places[places[0].map(len) >=3]
TypeError: object of type 'float' has no len()
问题已修复,这是更新的代码:
相关问题 更多 >
编程相关推荐