-4

I am trying to load a .csv file lying on my desktop using pandas on jupyter notebook and getting the following error:enter image description here


What's the problem with the code? The same method works on windows. (I'm using ubuntu 16.04 LTS)

U12-Forward
  • 65,118
  • 12
  • 70
  • 89
virmis_007
  • 155
  • 3
  • 17
  • Possible duplicate of [UnicodeDecodeError when reading CSV file in Pandas with Python](https://stackoverflow.com/questions/18171739/unicodedecodeerror-when-reading-csv-file-in-pandas-with-python) – Rishabh Agrahari Jun 23 '18 at 05:12
  • question has nothing to do with `machine-learning` - kindly do not spam the tag (removed) – desertnaut Jun 23 '18 at 10:43
  • Please do not post pictures of error messages and code, post the text directly here on SO. – Mr. T Jun 23 '18 at 10:53
  • @Mr. T Then in what scenario should the attach picture option be used? I posted picture because it was a too long error. – virmis_007 Jun 23 '18 at 11:15
  • Text should be posted as text, so it can be indexed and copied into an IDE or a search engine. Pictures are for graphs etc. Not sure, why you got a too long error - I have definitely seen longer questions. – Mr. T Jun 23 '18 at 11:26

2 Answers2

3

Try passing encoding='utf-8' argument in your read_csv function, like this:

data = pd.read_csv('file_name.csv', encoding='utf-8')

Hope this helps.

Rishabh Agrahari
  • 3,161
  • 2
  • 20
  • 21
0
filepath = r"/home/aditisp/Documents/Untitled Folder/sonar_data.csv"

df = pd.read_csv(filepath)

print(df.head())

This worked for me.

Aditi
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 30 '21 at 05:30