def replace_missing_data(df):
    """
    Replace missing numerical data with the median for each column.

    """
    for col in df.columns:
        if df[col].dtype == 'float64' or df[col].dtype == 'int64':
            df[col].fillna(df[col].median(), inplace=True)
    return df