def get_network_when(tnet, i=None, j=None, t=None, ij=None, logic='and', copy=False, asarray=False):
    """
    Returns subset of dataframe that matches index

    Parameters
    ----------
    tnet : df or TemporalNetwork
        TemporalNetwork object or pandas dataframe edgelist
    i : list or int
        get nodes in column i (source nodes in directed networks)
    j : list or int
        get nodes in column j (target nodes in directed networks)
    t : list or int
        get edges at this time-points.
    ij : list or int
        get nodes for column i or j (logic and can still persist for t). Cannot be specified along with i or j
    logic : str
        options: \'and\' or \'or\'. If \'and\', functions returns rows that corrspond that match all i,j,t arguments. If \'or\', only has to match one of them
    copy : bool
        default False. If True, returns a copy of the dataframe. Note relevant if hd5 data.
    asarray : bool
        default False. If True, returns the list of edges as an array.

    Returns
    -------
    df : pandas dataframe
        Unless asarray are set to true.
    """
    if isinstance(tnet, pd.DataFrame):
        network = tnet
        hdf5 = False
    # Can add hdfstore
    elif isinstance(tnet, object):
        network = tnet.network
        hdf5 = tnet.hdf5
    if ij is not None and (i is not None or j is not None):
        raise ValueError('ij cannoed be specifed along with i or j')
    # Make non list inputs a list
    if i is not None and not isinstance(i, list):
        i = [i]
    if j is not None and not isinstance(j, list):
        j = [j]
    if t is not None and not isinstance(t, list):
        t = [t]
    if ij is not None and not isinstance(ij, list):
        ij = [ij]
    if hdf5:
        if i is not None and j is not None and t is not None and logic == 'and':
            isinstr = 'i in ' + str(i) + ' & ' + 'j in ' + \
                str(j) + ' & ' + 't in ' + str(t)
        elif ij is not None and t is not None and logic == 'and':
            isinstr = '(i in ' + str(ij) + ' | ' + 'j in ' + \
                str(ij) + ') & ' + 't in ' + str(t)
        elif ij is not None and t is not None and logic == 'or':
            isinstr = 'i in ' + str(ij) + ' | ' + 'j in ' + \
                str(ij) + ' | ' + 't in ' + str(t)
        elif i is not None and j is not None and logic == 'and':
            isinstr = 'i in ' + str(i) + ' & ' + 'j in ' + str(j)
        elif i is not None and t is not None and logic == 'and':
            isinstr = 'i in ' + str(i) + ' & ' + 't in ' + str(t)
        elif j is not None and t is not None and logic == 'and':
            isinstr = 'j in ' + str(j) + ' & ' + 't in ' + str(t)
        elif i is not None and j is not None and t is not None and logic == 'or':
            isinstr = 'i in ' + str(i) + ' | ' + 'j in ' + \
                str(j) + ' | ' + 't in ' + str(t)
        elif i is not None and j is not None and logic == 'or':
            isinstr = 'i in ' + str(i) + ' | ' + 'j in ' + str(j)
        elif i is not None and t is not None and logic == 'or':
            isinstr = 'i in ' + str(i) + ' | ' + 't in ' + str(t)
        elif j is not None and t is not None and logic == 'or':
            isinstr = 'j in ' + str(j) + ' | ' + 't in ' + str(t)
        elif i is not None:
            isinstr = 'i in ' + str(i)
        elif j is not None:
            isinstr = 'j in ' + str(j)
        elif t is not None:
            isinstr = 't in ' + str(t)
        elif ij is not None:
            isinstr = 'i in ' + str(ij) + ' | ' + 'j in ' + str(ij)
        df = pd.read_hdf(network, where=isinstr)
    else:
        if i is not None and j is not None and t is not None and logic == 'and':
            df = network[(network['i'].isin(i)) & (
                network['j'].isin(j)) & (network['t'].isin(t))]
        elif ij is not None and t is not None and logic == 'and':
            df = network[((network['i'].isin(ij)) | (
                network['j'].isin(ij))) & (network['t'].isin(t))]
        elif ij is not None and t is not None and logic == 'or':
            df = network[((network['i'].isin(ij)) | (
                network['j'].isin(ij))) | (network['t'].isin(t))]
        elif i is not None and j is not None and logic == 'and':
            df = network[(network['i'].isin(i)) & (network['j'].isin(j))]
        elif i is not None and t is not None and logic == 'and':
            df = network[(network['i'].isin(i)) & (network['t'].isin(t))]
        elif j is not None and t is not None and logic == 'and':
            df = network[(network['j'].isin(j)) & (network['t'].isin(t))]
        elif i is not None and j is not None and t is not None and logic == 'or':
            df = network[(network['i'].isin(i)) | (
                network['j'].isin(j)) | (network['t'].isin(t))]
        elif i is not None and j is not None and logic == 'or':
            df = network[(network['i'].isin(i)) | (network['j'].isin(j))]
        elif i is not None and t is not None and logic == 'or':
            df = network[(network['i'].isin(i)) | (network['t'].isin(t))]
        elif j is not None and t is not None and logic == 'or':
            df = network[(network['j'].isin(j)) | (network['t'].isin(t))]
        elif i is not None:
            df = network[network['i'].isin(i)]
        elif j is not None:
            df = network[network['j'].isin(j)]
        elif t is not None:
            df = network[network['t'].isin(t)]
        elif ij is not None:
            df = network[(network['i'].isin(ij)) | (network['j'].isin(ij))]
        if copy:
            df = df.copy()
    if asarray:
        df = df.values
    return df
def get_network_when ( tnet , i = None , j = None , t = None , ij = None , logic = 'and' , copy = False , asarray = False ) : if isinstance ( tnet , pd . DataFrame ) : network = tnet hdf5 = False elif isinstance ( tnet , object ) : network = tnet . network hdf5 = tnet . hdf5 if ij is not None and ( i is not None or j is not None ) : raise ValueError ( 'ij cannoed be specifed along with i or j' ) if i is not None and not isinstance ( i , list ) : i = [ i ] if j is not None and not isinstance ( j , list ) : j = [ j ] if t is not None and not isinstance ( t , list ) : t = [ t ] if ij is not None and not isinstance ( ij , list ) : ij = [ ij ] if hdf5 : if i is not None and j is not None and t is not None and logic == 'and' : isinstr = 'i in ' + str ( i ) + ' & ' + 'j in ' + str ( j ) + ' & ' + 't in ' + str ( t ) elif ij is not None and t is not None and logic == 'and' : isinstr = '(i in ' + str ( ij ) + ' | ' + 'j in ' + str ( ij ) + ') & ' + 't in ' + str ( t ) elif ij is not None and t is not None and logic == 'or' : isinstr = 'i in ' + str ( ij ) + ' | ' + 'j in ' + str ( ij ) + ' | ' + 't in ' + str ( t ) elif i is not None and j is not None and logic == 'and' : isinstr = 'i in ' + str ( i ) + ' & ' + 'j in ' + str ( j ) elif i is not None and t is not None and logic == 'and' : isinstr = 'i in ' + str ( i ) + ' & ' + 't in ' + str ( t ) elif j is not None and t is not None and logic == 'and' : isinstr = 'j in ' + str ( j ) + ' & ' + 't in ' + str ( t ) elif i is not None and j is not None and t is not None and logic == 'or' : isinstr = 'i in ' + str ( i ) + ' | ' + 'j in ' + str ( j ) + ' | ' + 't in ' + str ( t ) elif i is not None and j is not None and logic == 'or' : isinstr = 'i in ' + str ( i ) + ' | ' + 'j in ' + str ( j ) elif i is not None and t is not None and logic == 'or' : isinstr = 'i in ' + str ( i ) + ' | ' + 't in ' + str ( t ) elif j is not None and t is not None and logic == 'or' : isinstr = 'j in ' + str ( j ) + ' | ' + 't in ' + str ( t ) elif i is not None : isinstr = 'i in ' + str ( i ) elif j is not None : isinstr = 'j in ' + str ( j ) elif t is not None : isinstr = 't in ' + str ( t ) elif ij is not None : isinstr = 'i in ' + str ( ij ) + ' | ' + 'j in ' + str ( ij ) df = pd . read_hdf ( network , where = isinstr ) else : if i is not None and j is not None and t is not None and logic == 'and' : df = network [ ( network [ 'i' ] . isin ( i ) ) & ( network [ 'j' ] . isin ( j ) ) & ( network [ 't' ] . isin ( t ) ) ] elif ij is not None and t is not None and logic == 'and' : df = network [ ( ( network [ 'i' ] . isin ( ij ) ) | ( network [ 'j' ] . isin ( ij ) ) ) & ( network [ 't' ] . isin ( t ) ) ] elif ij is not None and t is not None and logic == 'or' : df = network [ ( ( network [ 'i' ] . isin ( ij ) ) | ( network [ 'j' ] . isin ( ij ) ) ) | ( network [ 't' ] . isin ( t ) ) ] elif i is not None and j is not None and logic == 'and' : df = network [ ( network [ 'i' ] . isin ( i ) ) & ( network [ 'j' ] . isin ( j ) ) ] elif i is not None and t is not None and logic == 'and' : df = network [ ( network [ 'i' ] . isin ( i ) ) & ( network [ 't' ] . isin ( t ) ) ] elif j is not None and t is not None and logic == 'and' : df = network [ ( network [ 'j' ] . isin ( j ) ) & ( network [ 't' ] . isin ( t ) ) ] elif i is not None and j is not None and t is not None and logic == 'or' : df = network [ ( network [ 'i' ] . isin ( i ) ) | ( network [ 'j' ] . isin ( j ) ) | ( network [ 't' ] . isin ( t ) ) ] elif i is not None and j is not None and logic == 'or' : df = network [ ( network [ 'i' ] . isin ( i ) ) | ( network [ 'j' ] . isin ( j ) ) ] elif i is not None and t is not None and logic == 'or' : df = network [ ( network [ 'i' ] . isin ( i ) ) | ( network [ 't' ] . isin ( t ) ) ] elif j is not None and t is not None and logic == 'or' : df = network [ ( network [ 'j' ] . isin ( j ) ) | ( network [ 't' ] . isin ( t ) ) ] elif i is not None : df = network [ network [ 'i' ] . isin ( i ) ] elif j is not None : df = network [ network [ 'j' ] . isin ( j ) ] elif t is not None : df = network [ network [ 't' ] . isin ( t ) ] elif ij is not None : df = network [ ( network [ 'i' ] . isin ( ij ) ) | ( network [ 'j' ] . isin ( ij ) ) ] if copy : df = df . copy ( ) if asarray : df = df . values return df
Returns subset of dataframe that matches index

    Parameters
    ----------
    tnet : df or TemporalNetwork
        TemporalNetwork object or pandas dataframe edgelist
    i : list or int
        get nodes in column i (source nodes in directed networks)
    j : list or int
        get nodes in column j (target nodes in directed networks)
    t : list or int
        get edges at this time-points.
    ij : list or int
        get nodes for column i or j (logic and can still persist for t). Cannot be specified along with i or j
    logic : str
        options: \'and\' or \'or\'. If \'and\', functions returns rows that corrspond that match all i,j,t arguments. If \'or\', only has to match one of them
    copy : bool
        default False. If True, returns a copy of the dataframe. Note relevant if hd5 data.
    asarray : bool
        default False. If True, returns the list of edges as an array.

    Returns
    -------
    df : pandas dataframe
        Unless asarray are set to true.