-2

When I load and run the code below I get a UnicodeDecodeError. How to resolve this problem?

I have a CSV file in my folder but this type of error is coming and it will not show a list of heads in output. I use Jupyter notebook to run the codes as well as for programming.

import pandas as pd
companies=pd.read_csv('companies.csv')
round2=pd.read_csv('rounds2.csv')
print(round2.head())
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
  • Try `pd.read_csv('file_name.csv', encoding='utf-8')` – mhhabib Dec 24 '20 at 01:59
  • 3
    Does this answer your question? [UnicodeDecodeError when reading CSV file in Pandas with Python](https://stackoverflow.com/questions/18171739/unicodedecodeerror-when-reading-csv-file-in-pandas-with-python) – mhhabib Dec 24 '20 at 02:00
  • Please provide a [mcve], as well as the entire error output. What do you understand from that error message? Have you done any debugging? – AMC Dec 24 '20 at 02:32

1 Answers1

0

You could try companies=pd.read_csv('companies.csv', encoding = "ISO-8859-1") or companies=pd.read_csv('companies.csv', encoding = "utf-8")

Mitchell Olislagers
  • 1,758
  • 1
  • 4
  • 10