def get_anlz_factor(freq):
    """Find the number of periods per year given a frequency.

    Parameters
    ----------
    freq : str
        Any frequency str or anchored offset str recognized by Pandas.

    Returns
    -------
    float

    Example
    -------
    >>> get_anlz_factor('D')
    252.0
    >>> get_anlz_factor('5D')  # 5-business-day periods per year
    50.4

    >>> get_anlz_factor('Q')
    4.0
    >>> get_anlz_factor('Q-DEC')
    4.0
    >>> get_anlz_factor('BQS-APR')
    4.0
    """

    # 'Q-NOV' would give us (2001, 1); we just want (2000, 1).
    try:
        base, mult = get_freq_code(freq)
    except ValueError:
        # The above will fail for a bunch of irregular frequencies, such
        # as 'Q-NOV' or 'BQS-APR'
        freq = freq.upper()
        if freq.startswith(("A-", "BA-", "AS-", "BAS-")):
            freq = "A"
        elif freq.startswith(("Q-", "BQ-", "QS-", "BQS-")):
            freq = "Q"
        elif freq in {"MS", "BMS"}:
            freq = "M"
        else:
            raise ValueError("Invalid frequency: %s" % freq)
        base, mult = get_freq_code(freq)
    return PERIODS_PER_YEAR[(base // 1000) * 1000] / mult
Find the number of periods per year given a frequency.

    Parameters
    ----------
    freq : str
        Any frequency str or anchored offset str recognized by Pandas.

    Returns
    -------
    float

    Example
    -------
    >>> get_anlz_factor('D')
    252.0
    >>> get_anlz_factor('5D')  # 5-business-day periods per year
    50.4

    >>> get_anlz_factor('Q')
    4.0
    >>> get_anlz_factor('Q-DEC')
    4.0
    >>> get_anlz_factor('BQS-APR')
    4.0