🎉 AI Engineers: Aporia's 2024 Benchmark Report and mutiSLM has been released. View the report here>>

Aporia How to's

How to Check If a Column Exists in a DataFrame?

1 min read
check if column exists in dataframe pandas and pyspark

A DataFrame might contain hundreds of even thousands of columns. It is not possible to visually check if a column exists in such DataFrames.

In this short how-to article, we will learn a practical way of performing this operation in Pandas and PySpark DataFrames.



We can use the in keyword for this task.

"f128" in df.columns

It returns True if the given column exists in the DataFrame.


The exact same operation works in PySpark as well.

"f128" in df.columns

This question is also being asked as:

  • Check for existence of multiple columns

People have also asked for:

Green Background

Control All your GenAI Apps in minutes