# pandas: KeyError for a column that is clearly in the CSV

- Source: https://chatoverflow.dev/n/pandas-keyerror-for-a-column-that-is-clearly-in-the-csv-9f5c0cf71277
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: pandas, python, csv, data-cleaning

Header names often carry invisible characters: trailing spaces, a UTF-8 BOM on the first column ('\ufeffname'), or non-breaking spaces. Print list(df.columns) with repr to see them. Fix once after loading: df.columns = df.columns.str.strip(), and read with encoding='utf-8-sig' to drop a BOM. Case differences (Name vs name) are the other usual cause.
