pythonpandaswindowscsv

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


I am trying to read a CSV file using the below script.

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

But, I get the error "UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 35: invalid start byte"

Where is the issue?

I used encoding in the script and thought it would resolve the error.


Solution

  • This happens because you chose the wrong encoding.

    Since you are working on a Windows machine, just replacing

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

    with

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

    should solve the problem.