def assign_category(salts):
    """
    Identifies IL type based on name/str

    Parameters
    ----------
    salts: pandas DataFrame
        dataframe containing column with cation name

    Returns
    ----------
    salts: pandas DataFrame
        returns the same dataframe with categories
    """
    if "name-cation" in salts.columns:
        label = "name-cation"
    elif "Molecular Relative" in salts.columns:
        label = "Molecular Relative"
    else:
        print("No salt-name column found in DataFrame")
    category = []
    missed = []
    for i in range(salts.shape[0]):
        if ("imidazol" in salts[label].iloc[i]):
            category.append("Imidazolium")
        elif ("pyridin" in salts[label].iloc[i]):
            category.append("Pyridinium")
        elif ("pyrrolidin" in salts[label].iloc[i]):
            category.append("Pyrrolidinium")
        elif ("piperidin" in salts[label].iloc[i]):
            category.append("Piperidinium")
        elif ("phosphon" in salts[label].iloc[i]):
            category.append("Phosphonium")
        elif ("quinol" in salts[label].iloc[i]):
            category.append("Quinolinium")
        elif ("ammon" in salts[label].iloc[i]):
            category.append("Ammonium")
        elif ("amin" in salts[label].iloc[i]):
            category.append("Aminium")
        else:
            category.append("Other")
            missed.append(salts[label].iloc[i])
    print("ILs labeled as other: {}\n{}".format(len(missed), missed))
    salts["category"] = category
    return salts
def assign_category ( salts ) : if "name-cation" in salts . columns : label = "name-cation" elif "Molecular Relative" in salts . columns : label = "Molecular Relative" else : print ( "No salt-name column found in DataFrame" ) category = [ ] missed = [ ] for i in range ( salts . shape [ 0 ] ) : if ( "imidazol" in salts [ label ] . iloc [ i ] ) : category . append ( "Imidazolium" ) elif ( "pyridin" in salts [ label ] . iloc [ i ] ) : category . append ( "Pyridinium" ) elif ( "pyrrolidin" in salts [ label ] . iloc [ i ] ) : category . append ( "Pyrrolidinium" ) elif ( "piperidin" in salts [ label ] . iloc [ i ] ) : category . append ( "Piperidinium" ) elif ( "phosphon" in salts [ label ] . iloc [ i ] ) : category . append ( "Phosphonium" ) elif ( "quinol" in salts [ label ] . iloc [ i ] ) : category . append ( "Quinolinium" ) elif ( "ammon" in salts [ label ] . iloc [ i ] ) : category . append ( "Ammonium" ) elif ( "amin" in salts [ label ] . iloc [ i ] ) : category . append ( "Aminium" ) else : category . append ( "Other" ) missed . append ( salts [ label ] . iloc [ i ] ) print ( "ILs labeled as other: {}\n{}" . format ( len ( missed ) , missed ) ) salts [ "category" ] = category return salts
Identifies IL type based on name/str

    Parameters
    ----------
    salts: pandas DataFrame
        dataframe containing column with cation name

    Returns
    ----------
    salts: pandas DataFrame
        returns the same dataframe with categories