def sanitize_df(df):
    """Drops empty rows and columns from the DataFrame and returns it"""
    # Delete empty rows
    for i in df.index.tolist()[-1::-1]:
        if df.iloc[i].isna().all():
            df.drop(i, inplace=True)
        else:
            break
    # Delete empty columns
    cols = []
    for column in df:
        if not df[column].isnull().all():
            cols.append(column)
    df = df[cols]
    return df