Calendar.groupby#
- Calendar.groupby(grouper)#
Group dates by the grouper parameter.
- Allowed values for the grouper:
callable - the callable will receive the date and must return a hashable value
frequency criterion - a string representing a frequency
- Frequency criteria include:
W
: group by week number each year (same asW-SUN
)W-MON
: toW-SUN
group week ending on a particular weekdayM
: group by month each yearQ
: group by quarter each yearH
: group by semester each yearY
: group by year each year
- Parameters:
grouper (str, callable) – the criterion to group dates by
- Returns:
Collection of calendars
- Return type:
Example
Group dates by month
>>> calendar = Calendar(dates) >>> calendar.groupby("M") <doubledate.Collection at 0x7fd0fa52c2e0>
Group dates in half months
>>> calendar = Calendar(dates) >>> calendar.groupby(lambda date: (date.year, date.month, date.day < 15)) <doubledate.Collection at 0x7fd0fa52c2e0>