I’m trying to read one column from a csv (with header ‘Peptide Sequence’). However, this gives me the error as in the title. I know this probably has something to do with the encoding, which I know very little about. Is there a quick workaround for this?
JavaScript
x
5
1
import pandas as pd
2
file = r'C:...thpdb.csv'
3
df = pd.read_csv(file, usecols=['Peptide Sequence'])
4
print(df)
5
Advertisement
Answer
read_csv takes an encoding argument to deal with files in different formats, “ISO-8859-1” should work for you. See here:
JavaScript
1
5
1
import pandas as pd
2
file = r'C:...thpdb.csv'
3
df = pd.read_csv(file, usecols=['Peptide Sequence'], encoding = "ISO-8859-1")
4
print(df)
5