import logging


def remove_na(df):
    """
    Removes patient-visits whose data contains only missing values and fills in
    the remaining missing values with 0.

    :param pd.DataFrame df

    :rtype pd.DataFrame
    """

    logging.info('Cleaning missing values')

    result = df.dropna(how='all').copy()

    result.fillna(0., inplace=True)

    logging.info('Result is a table with shape {}'.format(df.shape))

    return result