簡體   English   中英

如何從數據框中刪除表情符號?

[英]How can I remove emojis from a dataframe?

我知道

test = []
for item in my_texts:
    test.append(item.encode('ascii', 'ignore').decode('ascii'))

從列表中刪除表情符號。 但是,如何從數據框中刪除表情符號? 當我嘗試

a = []
for item in goldtest['Text']:
    a.append(item.encode('ascii', 'ignore').decode('ascii'))

我僅獲得goldtest的最后一個條目。 當我在整個數據幀上嘗試代碼時,出現``AttributeError:'DataFrame'對象沒有屬性'encode'''

這將是與熊貓等效的代碼。 它逐列操作。

df.astype(str).apply(lambda x: x.str.encode('ascii', 'ignore').str.decode('ascii'))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM