def calculate_resource_timeseries(events, resource):
 import pandas as pd
 res = OrderedDict()
 all_res = 0.0
 for (tdelta, event) in sorted(events.items()):
  if (event[u'event'] == u'start'):
   if ((resource in event) and (event[resource] != u'Unknown')):
    all_res += float(event[resource])
   current_time = event[u'start']
  elif (event[u'event'] == u'finish'):
   if ((resource in event) and (event[resource] != u'Unknown')):
    all_res -= float(event[resource])
   current_time = event[u'finish']
  res[current_time] = all_res
 time_series = pd.Series(data=list(res.values()), index=list(res.keys()))
 ts_diff = time_series.diff()
 time_series = time_series[(ts_diff != 0)]
 return time_series

def calculate_resource_timeseries ( events , resource ) : import pandas as pd res = OrderedDict ( ) all_res = 0.0 for ( tdelta , event ) in sorted ( events . items ( ) ) : if ( event [ u'event' ] == u'start' ) : if ( ( resource in event ) and ( event [ resource ] != u'Unknown' ) ) : all_res += float ( event [ resource ] ) current_time = event [ u'start' ] elif ( event [ u'event' ] == u'finish' ) : if ( ( resource in event ) and ( event [ resource ] != u'Unknown' ) ) : all_res -= float ( event [ resource ] ) current_time = event [ u'finish' ] res [ current_time ] = all_res time_series = pd . Series ( data = list ( res . values ( ) ) , index = list ( res . keys ( ) ) ) ts_diff = time_series . diff ( ) time_series = time_series [ ( ts_diff != 0 ) ] return time_series
given as event dictionary .