def get_freq_label()

in src/smjsindustry/finance/utils.py [0:0]


def get_freq_label(date_value: str, freq: str) -> Callable:
    """Gets frequency label for the date value.

    Args:
        date_value (str): The date value.
        freq (str): The frequency value specifies how the date field should be aggregated,
            by year, quarter, month, week, day. Available values:
            ``{'Y', 'Q', 'M', 'W', 'D'}``, default ``'Q'``.

    Returns:
        python function: The function call to get date aggregated by certain frequency.
    """
    freq = freq.upper()
    if freq not in FREQ_LABEL_MAP:
        raise ValueError("frequency {} not supported".format(freq))
    if not isinstance(date_value, str):
        raise Exception("The date column needs to be string")
    return FREQ_LABEL_MAP[freq](date_value.upper())