def weighted_average(step: pd.DataFrame) -> pd.DataFrame:
    """
    Calculate weighted average from grouped data
    """

    data = np.ma.masked_array(step, np.isnan(step))
    data = np.ma.average(data, axis=0, weights=data[:, -2])
    data = data.filled(np.nan)

    return pd.DataFrame(data=[data], columns=step.columns)

    Calculate weighted average from grouped data
    
meteostat/utilities/aggregations.py