dataframe['Text'] = dataframe['Text'].apply(lambda x : ' '.join([item for item in string.split(x.lower()) if item not in stopwords]))
我正在从数据框中删除停用词。逻辑工作正常,但是当出现一些空行时会出现错误。
我使用了 dropna() 但它会删除整行,而不是其他列中的数据。
如何在上述逻辑中添加条件,即列 Text 不应为空
最佳答案
在你的逻辑之前使用,
dataframe.dropna(subset=['Text'], how='all')
关于python - 从数据框中删除停用词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43391516/