KeyError when indexing Pandas dataframe

As mentioned by alko, it is probably extra character at the beginning of your file.
When using read_csv, you can specify encoding to deal with encoding and heading character, known as BOM (Byte order mark)

df = pd.read_csv('values.csv', delimiter=",", encoding="utf-8-sig")

This question finds some echoes on Stackoverflow:
Pandas seems to ignore first column name when reading tab-delimited data, gives KeyError

Leave a Comment