# IndexGenerator

{% hint style="info" %}
In previous versions of RDT, this transformer was called `IDGenerator`.
{% endhint %}

**Compatibility:** `id` data

The `IndexGenerator` is used to create an indexed ID column that you may be using as a primary key. When transforming the data, it removes the column. When reversing the the transform, it creates an indexed ID column starting at a specified counter, with any additional prefixes or suffixes you provide.

<figure><img src="/files/1eYtGeweJB7XO3chhuCB" alt=""><figcaption></figcaption></figure>

```python
from rdt.transformers.text import IndexGenerator

transformer = IndexGenerator(prefix='ID_', starting_value=0, suffix='-synthetic')
```

## Parameters

**`prefix`**: A string with the prefix to use for the counter. All generated IDs will have the prefix.

<table data-header-hidden><thead><tr><th width="189.5"></th><th></th></tr></thead><tbody><tr><td>(default) <code>None</code></td><td>Do not add a prefix</td></tr><tr><td><code>&#x3C;string></code></td><td>Add the prefix to every ID</td></tr></tbody></table>

**`starting_value`**: The starting value for the counter

<table data-header-hidden><thead><tr><th width="189.5"></th><th></th></tr></thead><tbody><tr><td>(default) <code>0</code></td><td>Start the counter at 0.</td></tr><tr><td><code>&#x3C;integer></code></td><td>Use the integer as the starting value. This must be >=0.</td></tr></tbody></table>

**`suffix`**: A string with the suffix to use for the counter. All generated IDs will have the suffix.

<table data-header-hidden><thead><tr><th width="190.5"></th><th></th></tr></thead><tbody><tr><td>(default) <code>None</code></td><td>Do not add a suffix</td></tr><tr><td><code>&#x3C;string></code></td><td>Add the suffix to every ID</td></tr></tbody></table>

## FAQs

<details>

<summary>Will the generated IDs always be unique?</summary>

Yes. The generated IDs start at the `starting_value` parameter, and always increment by 1 for each new ID. Since there is no maximum value, the transformer will create unique IDs. (This is useful for primary keys.)

**Tip:** Use the [reset\_randomization](/rdt/usage/hypertransformer/transformation.md#reset_randomization) method to reset the counter back to the original `starting_value`.

</details>

<details>

<summary>When should I use this transformer?</summary>

The `IndexGenerator` is useful for ID columns that do not have any mathematical meaning. This transformer is useful for columns that represent indexed IDs, such as a primary key column.

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sdv.dev/rdt/transformers-glossary/id/indexgenerator.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
