Is there a way to check if a column exists in a Pandas DataFrame?
Suppose that I have the following DataFrame:
>>> import pandas as pd >&
This will work:
if 'A' in df:
But for clarity, I'd probably write it as:
if 'A' in df.columns: