Arthur Camberlein >> SEO & Data articles >> Find and remove empty column in Python with pandas

Find and remove empty column in Python with pandas

Written by Arthur Camberlein | Published on & updated on

Look for, find and delete/remove any empty column in a dataframe thanks to Python.


# Find the columns where each value is null
empty_cols = [col for col in df.columns if df[col].isnull().all()]

# Drop these columns from the dataframe
df.drop(empty_cols, 
  axis=1,
  inplace=True)

Find the columns where each value is null


empty_cols = [col for col in df.columns if df[col].isnull().all()]

Drop these columns from the dataframe


df.drop(empty_cols, axis=1, inplace=True)
Back to blog

Learn more with the article FAQ

Find and remove empty column in Python with pandas - FAQs

Blog post topic:  No topic assigned

Written by

Related Articles