Reputation: 530
I have a .csv file with a certain number of columns. One of the column has several values called Δ
(Greek letter Delta).
I tried to print the letter and I was successful:
print u'\u0394'
properly returns the Greek letter.
However, if I try to select the rows of the file containing Δ
in the column called 'column'
, using
file=pd.read_csv('filename.csv',sep=';')
print file[file['column']==u'\u0394']
I find myself with an empty list, even though I know that some rows do have Δ
in that column.
What am I doing wrong?
Upvotes: 1
Views: 2069
Reputation: 19123
You must add encoding='utf-8'
to read_csv, because python 2 does not default to unicode strings (and byte strings can't deal with Delta). You don't get anything because Pandas silently ignores the failure when reading the string:
file=pd.read_csv('filename.csv', sep=';', encoding='utf-8')
Upvotes: 3