def group_days_by(days, criterion):
    """
    Group the given vector of days according to the given criterion.

    Parameters
    ----------
    days: pd.DatetimeIndex
    criterion: str
        Indicates how to group the given days. It can be either "year" or "month" or "season".
        (The meteorological seasons are considered, and not the astronomical ones)

    Returns
    ----------
    list
        List of pairs (i.e. tuples).
        Each pair is a group of days.
            - The first element is a string which represents the group name (i.e. group label).
            - The second element is the vector of days in that group, i.e. it's a pd.DatetimeIndex.

    Raises
    ----------
    ValueError
        When `criterion` is neither "year" nor "month" nor "season".

    Notes
    ----------
    For the sake of completeness, it's important to say that if `criterion` is either "month" or "season", also days of
    different years could be grouped together.
    """
    days = days.sort_values()
    if criterion=="year":
        years = days.year.drop_duplicates()
        return [(str(year),days[days.year==year]) for year in years]
    elif criterion=="month":
        def stringify_month(month):
            return ["January","February","March","April","May","June","July","August","September",
                    "October","November","December"][month-1]
        months = days.month.drop_duplicates()
        return [(stringify_month(month),days[days.month==month]) for month in months]
    elif criterion=="season":
        def to_season(month):
            return ["Winter", "Spring", "Summer", "Fall"][month%12//3]
        seasons = days.month.map(lambda month: to_season(month)).drop_duplicates()
        return [(season,days[list(days.month.map(lambda month: to_season(month)==season))]) for season in seasons]
    else:
        raise ValueError("criterion must be either \"year\" or \"month\" or \"season\" ")