UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 35: invalid start byte

This happens because you chose the wrong encoding.

Since you are working on a Windows machine, just replacing

Past=pd.read_csv("C:/Users/Admin/Desktop/Python/Past.csv",encoding='utf-8') 

with

Past=pd.read_csv("C:/Users/Admin/Desktop/Python/Past.csv",encoding='cp1252')

should solve the problem.


Use this solution it will strip out (ignore) the characters and return the string without them. Only use this if your need is to strip them not convert them.

with open(path, encoding="utf8", errors='ignore') as f:

Using errors='ignore' You'll just lose some characters. but if your don't care about them as they seem to be extra characters originating from a the bad formatting and programming of the clients connecting to my socket server. Then its a easy direct solution. reference


Try using :

pd.read_csv(“Your filename", encoding="ISO-8859-1”)

The code that I parsed from some website was converted in this encoding instead of default UTF-8 encoding which is standard.

Tags:

Python

Pandas

Csv