I have a dictionary WO
of the format:
WO = {datetime: {'V1', 'V2', 'V3', 'V4'}}
Where datetime
is the key of the (example) format:
datetime.date(2014, 6, 20)
And V1
through V4
are lists containing floating values.
Example:
WO = {datetime.date(2014, 12, 20): {'V1': [11, 15, 19],
'V2': [12, 3, 4],
'V3': [50, 55, 56],
'V4': [100, 112, 45]},
datetime.date(2014, 12, 21): {'V1': [10, 12, 9],
'V2': [16, 13, 40],
'V3': [150, 155, 156],
'V4': [1100, 1132, 457]},
datetime.date(2014, 12, 22): {'V1': [107, 172, 79],
'V2': [124, 43, 44],
'V3': [503, 552, 561],
'V4': [1000, 1128, 457]}}
If I want to aggregate values in V1
through to V4
according to the week for a given date, for example:
my_date = datetime.date(2014, 5, 23)
For this given date, aggregate all values in V1
through to V4
for this week, where the week starts from Monday.
year, week, weekday = datetime.date(my_date).isocalendar()
This line gives me the week and weekday for this particular date.
If I have a function as:
def week(date):
'''
date is in 'datetime.date(year, month, date)' format
This function is supposed to aggregate values in 'V1', 'V2', 'V3' and
'V4' for a whole week according to the parameter 'date'
'''
How should I proceed next to define such a function?