Mercurial Hosting > traffic-intelligence
comparison scripts/process.py @ 1084:1a7e0b2c858b
remove debugging
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 24 Jul 2018 01:24:42 -0400 |
parents | 5b597b021aed |
children | 8734742c08c0 |
comparison
equal
deleted
inserted
replaced
1083:5b597b021aed | 1084:1a7e0b2c858b |
---|---|
334 # plt.close() | 334 # plt.close() |
335 elif args.output == 'event': | 335 elif args.output == 'event': |
336 data.to_csv(args.eventFilename, index = False) | 336 data.to_csv(args.eventFilename, index = False) |
337 | 337 |
338 if args.analyze == 'event-speed': # aggregate event data by 15 min interval (args.intervalDuration), count events with thresholds | 338 if args.analyze == 'event-speed': # aggregate event data by 15 min interval (args.intervalDuration), count events with thresholds |
339 data = pd.read_csv(args.eventFilename, parse_dates = [2], nrows = 10000) | 339 data = pd.read_csv(args.eventFilename, parse_dates = [2]) |
340 #data = pd.read_csv('./speeds.csv', converters = {'time': lambda s: datetime.datetime.strptime(s, "%H:%M:%S").time()}, nrows = 5000) | 340 #data = pd.read_csv('./speeds.csv', converters = {'time': lambda s: datetime.datetime.strptime(s, "%H:%M:%S").time()}, nrows = 5000) |
341 # create time for end of each 15 min, then group by, using the agg method for each data column | 341 # create time for end of each 15 min, then group by, using the agg method for each data column |
342 headers = ['site', 'date', 'intervalend15', 'duration', 'count'] | 342 headers = ['site', 'date', 'intervalend15', 'duration', 'count'] |
343 aggFunctions, tmpheaders = utils.aggregationMethods(args.aggMethods, args.aggCentiles) | 343 aggFunctions, tmpheaders = utils.aggregationMethods(args.aggMethods, args.aggCentiles) |
344 dataColumns = list(data.columns[4:]) | 344 dataColumns = list(data.columns[4:]) |
371 row.append((group[h] > t).sum()) | 371 row.append((group[h] > t).sum()) |
372 outputData.append(row) | 372 outputData.append(row) |
373 pd.DataFrame(outputData, columns = headers).to_csv(utils.removeExtension(args.eventFilename)+'-aggregated.csv', index = False) | 373 pd.DataFrame(outputData, columns = headers).to_csv(utils.removeExtension(args.eventFilename)+'-aggregated.csv', index = False) |
374 | 374 |
375 elif args.analyze == 'event-interaction': # aggregate event data by 15 min interval (args.intervalDuration), count events with thresholds | 375 elif args.analyze == 'event-interaction': # aggregate event data by 15 min interval (args.intervalDuration), count events with thresholds |
376 data = pd.read_csv(args.eventFilename, parse_dates = [2], nrows = 20000) | 376 data = pd.read_csv(args.eventFilename, parse_dates = [2]) |
377 headers = ['site', 'date', 'intervalend15', 'duration', 'count'] | 377 headers = ['site', 'date', 'intervalend15', 'duration', 'count'] |
378 aggFunctions, tmpheaders = utils.aggregationMethods(args.aggMethods, args.aggCentiles) | 378 aggFunctions, tmpheaders = utils.aggregationMethods(args.aggMethods, args.aggCentiles) |
379 dataColumns = list(data.columns[3:]) | 379 dataColumns = list(data.columns[3:]) |
380 for h in dataColumns: | 380 for h in dataColumns: |
381 if not 'speed' in h.lower(): # proximity indicators are reversed, taking 85th centile of this column will yield the 15th centile (which we have to take the opposite again) | 381 if not 'speed' in h.lower(): # proximity indicators are reversed, taking 85th centile of this column will yield the 15th centile (which we have to take the opposite again) |