I have a dataset with columns 'Start time', 'End Time', 'Process' eg 10:00, 11:00, A 11:00, 12:00, A 12:00, 13:00, B 14:00, 15:00, C 15:00, 16:00, C I want my output as 10:00, 12:00, A 12:00, 13:00, B 14:00, 16:00, C If you see I have clubbed the process and corresponding start and end time are also changes to start time of first occurrence and end time of last occurrence. Any help will be appreciated
processdict = {} # for each item in the existing dataset if item.processname not in processdict: # this process not in the dictionary # add a new entry with the current times times = [item.starttime, item.endtime] processdict[item.processname] = times else: # this process is in the dictionary # if the start time is earlier than the dictionary entry # replace it with this element's start time if item.starttime < processdict[item.processname].value[0]: processdict[item.processname].value[0] = item.starttime # as above but replacing with later end times if item.endtime > processdict[item.processname].value[1]: processdict[item.processname].value[1] = item.endtime
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)