Standardize names and values - agate 1.12.0 documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# Standardize names and values

## Standardize row and columns names

The `Table.rename()` method has arguments to convert row or column names to slugs and append unique identifiers to duplicate values.

Using an existing table object:

    # Convert column names to unique slugs
    table.rename(slug_columns=True)

    # Convert row names to unique slugs
    table.rename(slug_rows=True)

    # Convert both column and row names to unique slugs
    table.rename(slug_columns=True, slug_rows=True)

## Standardize column values

agate has a `Slug` computation that can be used to also standardize text column values. The computation has an option to also append unique identifiers to duplicate values.

Using an existing table object:

    # Convert the values in column 'title' to slugs
    new_table = table.compute([
        ('title-slug', agate.Slug('title'))
    ])

    # Convert the values in column 'title' to unique slugs
    new_table = table.compute([
        ('title-slug', agate.Slug('title', ensure_unique=True))
    ])