I downloaded a dataset from Kaggle and am trying to execute the following code:
import pandas as pd
movie_data = pd.read_csv('moviemetadata.csv', encoding = 'utf-8', delimiter = ',', header=0, decimal = '.')
print(movie_data.info)
Curiously, when I'm trying to run it inside Sublime Text or the Terminal (I'm on a Mac), it won't work and the following error gets thrown out:
Traceback (most recent call last):
File ".../test.py", line 14, in <module>
print(movie_data.info) #UnicodeEncodeError: 'ascii' codec can't encode character '\xe5' in position 7356: ordinal not in range(128)
UnicodeEncodeError: 'ascii' codec can't encode character '\xf3' in position 7559: ordinal not in range(128)
I googled this error message and tried to find a fix, for example by including the "encoding = 'utf-8'", but this didn't fix it. I then tried to run the same code in jupyter, and it works flawlessly. I get exactly the output I want.
Does somebody have an idea what causes this and how I could get the same code to work in the terminal also?
Additional info: I'm using the same Python version in terminal and jupyter, and I saved the .csv specifically with utf-8 encoding.