def imdb_iM_table(imodulon_table, cat_order=None):
    """
    Reformats the iModulon table according

    Parameters
    ----------
    imodulon_table : ~pandas.DataFrame
        Table formatted similar to IcaData.imodulon_table
    cat_order : list, optional
        List of categories in imodulon_table.category, ordered as desired

    Returns
    -------
    im_table: ~pandas.DataFrame
        New iModulon table with the columns expected by iModulonDB
    """

    im_table = imodulon_table[
        [
            "name",
            "regulator_readable",
            "function",
            "category",
            "n_genes",
            "exp_var",
            "precision",
            "recall",
        ]
    ].copy()
    im_table.index.name = "k"
    im_table.category = im_table.category.fillna("Uncharacterized")

    if cat_order is not None:
        cat_dict = {val: i for i, val in enumerate(cat_order)}
        im_table.loc[:, "category_num"] = [
            cat_dict[im_table.category[k]] for k in im_table.index
        ]
    else:
        try:
            im_table.loc[:, "category_num"] = imodulon_table["new_idx"]
        except KeyError:
            im_table.loc[:, "category_num"] = im_table.index

    return im_table