Exemplo n.º 1
0
def agents(entry, exit, decom, info):
    """Computes the Agents table. This is tricky because both the AgentExit
    table and the DecomSchedule table may not be present in the database.
    Furthermore, the Info table does not contain the AgentId column. This
    computation handles the calculation of the ExitTime in the face a
    significant amounts of missing data.
    """
    mergeon = ['SimId', 'AgentId']
    ent = tools.raw_to_series(entry, ['SimId', 'AgentId'], 'Kind')
    idx = ent.index
    df = entry[[
        'SimId', 'AgentId', 'Kind', 'Spec', 'Prototype', 'ParentId',
        'Lifetime', 'EnterTime'
    ]]
    if exit is None:
        agent_exit = pd.Series(index=idx, data=[np.nan] * len(idx))
        agent_exit.name = 'ExitTime'
    else:
        agent_exit = agent_exit.reindex(index=idx)
    df = pd.merge(df, agent_exit.reset_index(), on=mergeon)
    if decom is not None:
        df = tools.merge_and_fillna_col(
            df,
            decom[['SimId', 'AgentId', 'DecomTime']],
            'ExitTime',
            'DecomTime',
            on=mergeon)
    df = tools.merge_and_fillna_col(df,
                                    info[['SimId', 'Duration']],
                                    'ExitTime',
                                    'Duration',
                                    on=['SimId'])
    return df
Exemplo n.º 2
0
def agents(series):
    """Computes the Agents table. This is tricky because both the AgentExit
    table and the DecomSchedule table may not be present in the database.
    Furthermore, the Info table does not contain the AgentId column. This
    computation handles the calculation of the ExitTime in the face a 
    significant amounts of missing data.
    """
    mergeon  = ['SimId', 'AgentId']
    idx = series[0].index
    df = series[0].reset_index()
    for s in series[1:6]:
        df = pd.merge(df, s.reset_index(), on=mergeon)
    agent_exit = series[6]
    if agent_exit is None:
        agent_exit = pd.Series(index=idx, data=[np.nan]*len(idx))
        agent_exit.name = 'ExitTime'
    else:
        agent_exit = agent_exit.reindex(index=idx)
    df = pd.merge(df, agent_exit.reset_index(), on=mergeon)
    decom_time = series[7]
    if decom_time is not None:
        df = tools.merge_and_fillna_col(df, decom_time.reset_index(), 
                                        'ExitTime', 'DecomTime', on=mergeon)
    duration = series[8]
    df = tools.merge_and_fillna_col(df, duration.reset_index(), 
                                    'ExitTime', 'Duration', on=['SimId'])
    return df
Exemplo n.º 3
0
def agents(series):
    """Computes the Agents table. This is tricky because both the AgentExit
    table and the DecomSchedule table may not be present in the database.
    Furthermore, the Info table does not contain the AgentId column. This
    computation handles the calculation of the ExitTime in the face a 
    significant amounts of missing data.
    """
    mergeon = ['SimId', 'AgentId']
    idx = series[0].index
    df = series[0].reset_index()
    for s in series[1:6]:
        df = pd.merge(df, s.reset_index(), on=mergeon)
    agent_exit = series[6]
    if agent_exit is None:
        agent_exit = pd.Series(index=idx, data=[np.nan] * len(idx))
        agent_exit.name = 'ExitTime'
    else:
        agent_exit = agent_exit.reindex(index=idx)
    df = pd.merge(df, agent_exit.reset_index(), on=mergeon)
    decom_time = series[7]
    if decom_time is not None:
        df = tools.merge_and_fillna_col(df,
                                        decom_time.reset_index(),
                                        'ExitTime',
                                        'DecomTime',
                                        on=mergeon)
    duration = series[8]
    df = tools.merge_and_fillna_col(df,
                                    duration.reset_index(),
                                    'ExitTime',
                                    'Duration',
                                    on=['SimId'])
    return df
Exemplo n.º 4
0
def agents(entry, exit, decom, info):
    """Computes the Agents table. This is tricky because both the AgentExit
    table and the DecomSchedule table may not be present in the database.
    Furthermore, the Info table does not contain the AgentId column. This
    computation handles the calculation of the ExitTime in the face a
    significant amounts of missing data.
    """
    mergeon = ['SimId', 'AgentId']
    df = entry[[
        'SimId', 'AgentId', 'Kind', 'Spec', 'Prototype', 'ParentId',
        'Lifetime', 'EnterTime'
    ]]
    df['ExitTime'] = [np.nan] * len(entry)
    if exit is not None:
        exit.columns = ['SimId', 'AgentId', 'Exits']
        df = tools.merge_and_fillna_col(df,
                                        exit[['SimId', 'AgentId', 'Exits']],
                                        'ExitTime',
                                        'Exits',
                                        on=mergeon)
    if decom is not None:
        df = tools.merge_and_fillna_col(
            df,
            decom[['SimId', 'AgentId', 'DecomTime']],
            'ExitTime',
            'DecomTime',
            on=mergeon)
    df = tools.merge_and_fillna_col(df,
                                    info[['SimId', 'Duration']],
                                    'ExitTime',
                                    'Duration',
                                    on=['SimId'])
    return df
Exemplo n.º 5
0
def agents(entry, exit, decom, info):
    """Computes the Agents table. This is tricky because both the AgentExit
    table and the DecomSchedule table may not be present in the database.
    Furthermore, the Info table does not contain the AgentId column. This
    computation handles the calculation of the ExitTime in the face a
    significant amounts of missing data.
    """
    mergeon = ['SimId', 'AgentId']
    ent = tools.raw_to_series(entry, ['SimId', 'AgentId'], 'Kind')
    idx = ent.index
    df = entry[['SimId', 'AgentId', 'Kind', 'Spec', 'Prototype', 'ParentId',
                'Lifetime', 'EnterTime']]
    if exit is None:
        agent_exit = pd.Series(index=idx, data=[np.nan]*len(idx))
        agent_exit.name = 'ExitTime'
    else:
        agent_exit = agent_exit.reindex(index=idx)
    df = pd.merge(df, agent_exit.reset_index(), on=mergeon)
    if decom is not None:
        df = tools.merge_and_fillna_col(df, decom[['SimId', 'AgentId', 'DecomTime']],
                                        'ExitTime', 'DecomTime', on=mergeon)
    df = tools.merge_and_fillna_col(df, info[['SimId', 'Duration']],
                                    'ExitTime', 'Duration', on=['SimId'])
    return df