def new(dataframe: pd.DataFrame, filename: str):
    '\n    Writes a dynamo table file from a pandas DataFrame\n    :param dataframe: pandas dataframe with headings matching the name from the dynamo table convention\n    :param filename: file in which to save data from dataframe, should end in .tbl\n    :return:\n    '
    n_rows = dataframe.shape[0]
    if (('tomo_file' in dataframe.columns) and ('tomo' not in dataframe.columns)):
        tomo_names = dataframe['tomo_file'].unique()
        tomo_name_idx = {name: index for (index, name) in enumerate(tomo_names)}
        tomo_idx = [tomo_name_idx[name] for name in dataframe['tomo_file']]
        dataframe['tomo'] = tomo_idx
    if ('tag' not in dataframe.columns):
        tags = [(x + 1) for x in range(n_rows)]
        dataframe['tag'] = tags
    zeros = [0 for x in range(n_rows)]
    ones = [1 for x in range(n_rows)]
    data = {}
    for column_name in COLUMN_NAMES:
        if (column_name in dataframe.columns):
            data[column_name] = dataframe[column_name]
        elif ((column_name not in dataframe.columns) and (column_name == 'aligned_value')):
            data[column_name] = ones
        else:
            data[column_name] = zeros
    table = pd.DataFrame.from_dict(data)
    filename = str(filename)
    if (not filename.endswith('.tbl')):
        filename = filename.join('.tbl')
    table.to_csv(filename, sep=' ', header=False, index=False)
    if ('tomo_file' in dataframe.columns):
        table_file_name = filename.replace('.tbl', '.doc')
        table_map = dataframe[['tomo', 'tomo_file']].drop_duplicates(subset='tomo')
        table_map.to_csv(table_file_name, sep=' ', header=False, index=False)
    return
Writes a dynamo table file from a pandas DataFrame
:param dataframe: pandas dataframe with headings matching the name from the dynamo table convention
:param filename: file in which to save data from dataframe, should end in .tbl
:return:
def new(dataframe: pd.DataFrame, filename: str):
    '\n    Writes a dynamo table file from a pandas DataFrame\n    :param dataframe: pandas dataframe with headings matching the name from the dynamo table convention\n    :param filename: file in which to save data from dataframe, should end in .tbl\n    :return:\n    '
    n_rows = dataframe.shape[0]
    if (('tomo_file' in dataframe.columns) and ('tomo' not in dataframe.columns)):
        tomo_names = dataframe['tomo_file'].unique()
        tomo_name_idx = {name: index for (index, name) in enumerate(tomo_names)}
        tomo_idx = [tomo_name_idx[name] for name in dataframe['tomo_file']]
        dataframe['tomo'] = tomo_idx
    if ('tag' not in dataframe.columns):
        tags = [(x + 1) for x in range(n_rows)]
        dataframe['tag'] = tags
    zeros = [0 for x in range(n_rows)]
    ones = [1 for x in range(n_rows)]
    data = {}
    for column_name in COLUMN_NAMES:
        if (column_name in dataframe.columns):
            data[column_name] = dataframe[column_name]
        elif ((column_name not in dataframe.columns) and (column_name == 'aligned_value')):
            data[column_name] = ones
        else:
            data[column_name] = zeros
    table = pd.DataFrame.from_dict(data)
    filename = str(filename)
    if (not filename.endswith('.tbl')):
        filename = filename.join('.tbl')
    table.to_csv(filename, sep=' ', header=False, index=False)
    if ('tomo_file' in dataframe.columns):
        table_file_name = filename.replace('.tbl', '.doc')
        table_map = dataframe[['tomo', 'tomo_file']].drop_duplicates(subset='tomo')
        table_map.to_csv(table_file_name, sep=' ', header=False, index=False)
    return