def idxToResid(idx, nodes, idOnly=False):
    """
    This function takes in some node index and generates
    a string code of one-letter residue name and integer of residue number.

    Parameters
    ----------
    idx : int
        integer index of the pandas dataframe
    nodes : pandas dataframe
        pandas dataframe of which to search
    idOnly : Boolean
        True to return numpy.int64 of residue number
        False to return code with resname abbrev
        ex., True returns 150; False returns 'F150:sc'

    Returns
    -------
    string or numpy.int64 value of residue (based on idOnly parameter)

    """
    aa_dict = {'CYS': 'C', 'ASP': 'D', 'SER': 'S', 'GLN': 'Q', 'LYS': 'K',
     'ILE': 'I', 'PRO': 'P', 'THR': 'T', 'PHE': 'F', 'ASN': 'N',
     'GLY': 'G', 'HIS': 'H', 'HSD': 'H', 'LEU': 'L', 'ARG': 'R', 'TRP': 'W',
     'ALA': 'A', 'VAL':'V', 'GLU': 'E', 'TYR': 'Y', 'MET': 'M',
     'GBI1':'GBI1', 'GBI2':'GBI2', 'WAT':'WAT'}

    #old way not conducive to taking diff of dataframes
    #entry = nodes.iloc[idx-1]
    entry = nodes.loc[nodes.index == idx] # iloc gives series, loc gives dataframe
    entry = entry.T.squeeze() # convert from dataframe to series
    resname = entry['resname']
    if resname in ['GBI1','GBI2']:
        code = aa_dict[resname]+':'+entry['code']
    elif resname == 'WAT':
        code = aa_dict[resname]+str(entry['resid'])
    else: # if not GBI or WAT, must be Hv1
        if idOnly: code = entry['resid']
        else: code = aa_dict[resname]+str(entry['resid'])+':'+entry['location']

    return code