2024-09-27 09:37:25 发布
网友
我有一个CSV文件以“latin1”编码打开。然而,阅读表情符号似乎有问题。我想删除所有的表情符号。它显示为方形框,当我更改为列表时,它将更改为“\x80”。有什么办法可以移除这个
df = pd.read_csv(r"myfilepath", encoding='latin1')
尝试ASCII转换,尽管这是用于删除表情符号:
l_data = [x.encode('ascii', 'ignore').decode('ascii') for x in l_data]
如果要删除特定字符,请执行以下操作:
l_data = [x.replace('\x80', '') for x in l_data]
以this为动机的答复
试试这个
df = pd.read_csv(r"myfilepath", encoding='iso-8859-1')
请参阅下面的链接
UnicodeEncodeError : 'charmap' codec can't encode character '\x80' in position 0 : character maps to <undefined>
尝试ASCII转换,尽管这是用于删除表情符号:
如果要删除特定字符,请执行以下操作:
以this为动机的答复
试试这个
df = pd.read_csv(r"myfilepath", encoding='iso-8859-1')
请参阅下面的链接
UnicodeEncodeError : 'charmap' codec can't encode character '\x80' in position 0 : character maps to <undefined>
相关问题 更多 >
编程相关推荐