Mercurial Hosting > traffic-intelligence
diff trafficintelligence/utils.py @ 1077:3939ae415be0
Merging
author | Wendlasida |
---|---|
date | Fri, 20 Jul 2018 14:03:34 -0400 |
parents | c04550f957ab |
children | 8734742c08c0 |
line wrap: on
line diff
--- a/trafficintelligence/utils.py Fri Jul 20 13:50:43 2018 -0400 +++ b/trafficintelligence/utils.py Fri Jul 20 14:03:34 2018 -0400 @@ -342,6 +342,10 @@ def timeToFrames(t, frameRate): return frameRate*(t.hour*3600+t.minute*60+t.second) +def timeModulo(t, duration): + 'returns the time modulo the duration in min' + return time(t.hour, t.minute//duration, t.second) + def sortXY(X,Y): 'returns the sorted (x, Y(x)) sorted on X' D = {} @@ -591,6 +595,19 @@ print('Unknown aggregation method: {}'.format(funcStr)) return None +def aggregationMethods(methods, centiles = None): + aggFunctions = {} + headers = [] + for method in methods: + if method == 'centile': + aggFunctions[method] = aggregationFunction(method, centiles) + for c in centiles: + headers.append('{}{}'.format(method,c)) + else: + aggFunctions[method] = aggregationFunction(method) + headers.append(method) + return aggFunctions, headers + ######################### # regression analysis using statsmodels (and pandas) #########################