For the first question about getting first monday automatically, you could use busday_offset to do so defining a weekday mask to consider only mondays to be busdays:
firstDay = np.min(log[:, 0]) firstMonday = first_monday(firstDay) def first_monday(firstDay): firstEntry = firstDay.astype('M8[D]') beforeMonday = np.busday_offset(firstEntry, -1, 'forward', [1,0,0,0,0,0,0]) if firstEntry - beforeMonday == np.timedelta64(7, 'D'): return firstEntry else: return beforeMonday