How to check if a column exists in Pandas

The Solution to How to check if a column exists in Pandas is


This will work:

if 'A' in df:

But for clarity, I'd probably write it as:

if 'A' in df.columns:

~ Answered on 2014-07-21 16:48:49


Most Viewed Questions: