-1

I am trying to run a code on a friend's PC. The same code runs perfectly fine on my PC. But, is generating the following error on my friend's PC:

'utf-8' codec can't decode byte 0xd4 in position 2523: invalid continuation byte File "C:\Users\t848451\Desktop\Phone and User Report\Phone_User_Report_Macro (1).py", line 6, in df_phone=pd.read_csv("Phone_Report.csv", engine='python')

The code is:

import pandas as pd
import re as re
import calendar
import datetime

df_phone=pd.read_csv("Phone_Report.csv")

Any help would be greatly appreciated.

user11427018
  • 129
  • 1
  • 6

1 Answers1

-1

I think you should not add any images in here. Anyway try to add encoding="UTF-8" in the parameter of pd.read_csv. or try some other encodings.

  • Hi, thanks for your feedback. I have updated my question. Is there a reason why this needs to be added in my coworker's version but not mine? – user11427018 Apr 26 '22 at 15:57
  • I am not an expert but I think different os use different encodings for various purposes and sometimes you just need to explicitly set the parameter for compatibility. [List of Python standard encodings](https://docs.python.org/3/library/codecs.html#standard-encodings) – Wasikur Rahman Apr 26 '22 at 16:08
  • I changed my code to: df_phone=pd.read_csv('Phone_Report.csv', encoding='utf-8') – user11427018 Apr 26 '22 at 16:17
  • But I am still getting the same error – user11427018 Apr 26 '22 at 16:17
  • then try some other encodings. [this](https://stackoverflow.com/a/30470630/13193861) might help. – Wasikur Rahman Apr 26 '22 at 16:24