Compatibility: text data

The IDGenerator 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.

from rdt.transformers.text import IDGenerator

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


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

(default) None

Do not add a prefix


Add the prefix to every ID

starting_value: The starting value for the counter

(default) 0

Start the counter at 0.


Use the integer as the starting value. This must be >=0.

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

(default) None

Do not add a suffix


Add the suffix to every ID


Will the generated IDs always be unique?

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 method to reset the counter back to the original starting_value.

When should I use this transformer?

The IDGenerator 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.

Last updated