def prepare_dataframe_for_anomaly(df_sub_dim, date_column, agg_dict, frequency="D"):
    """Performs resampling and aggregation to prepare the input DataFrame to be used for Anomaly Detection

    :param df_sub_dim: A pandas DataFrame for some sub-dimension
    :type df_sub_dim: pandas.core.frame.DataFrame
    :param date_column: Name of the column containing the date/timeperiod
    :type date_column: str
    :param agg_dict: Aggregation dictionary specifying the columns and aggregation functions to perform in resampling.
    :type agg_dict: Dict
    :param frequency: Aggregation frequency key using pandas standards (https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases), defaults to 'D'
    :type frequency: str, optional
    :return: Returns the resampled and aggregated pandas DataFrame.
    :rtype: pandas.core.frame.DataFrame
    """
    return (
        df_sub_dim.set_index(date_column)
        .resample(frequency)
        .agg(agg_dict)
        .reset_index()
    )