janitor.remove_empty

janitor.remove_empty(df: pandas.core.frame.DataFrame) → pandas.core.frame.DataFrame[source]

Drop all rows and columns that are completely null.

This method also resets the index(by default) since it doesn’t make sense to preserve the index of a completely empty row.

This method mutates the original DataFrame.

Implementation is inspired from StackOverflow.

Functional usage syntax:

df = remove_empty(df)

Method chaining syntax:

import pandas as pd
import janitor
df = pd.DataFrame(...).remove_empty()
Parameters

df – The pandas DataFrame object.

Returns

A pandas DataFrame.