Skip to main content

Realistic data corruption (based on GeCo).

Project description


PyPI PyPI - License PyPI - Python Version

Want to realistically corrupt your (textual) data? Use Corruptor!

pip install corruptor

The supported type of corruptions:

  • OCR variation
  • Phonetic variation
  • Typing error
  • Edit (insert, delete, replace, swap)

Getting started

There are three different classes that can be used.


The basic corruptor provides methods for each type of corruption, using default configuration.

>>> from corruptor import BasicCorruptor
>>> basic = BasicCorruptor()
>>> basic.ocr('johnson')
>>> basic.phonetic('johnson')
>>> basic.typo('johnson')
>>> basic.insert('johnson')
>>> basic.delete('johnson')
>>> basic.replace('johnson')
>>> basic.swap('johnson')


This class selects the type of corruption at random, based on provided weights.

>>> from corruptor import ProbabilisticCorruptor
>>> prob = ProbabilisticCorruptor({'none': 0.33, 'phonetic': 0.33, 'typo': 0.33})
>>> prob.corrupt('conner')
>>> prob.corrupt('conner')
>>> prob.corrupt('conner')


In short, the DataFrame corruptor randomly corrupts n rows of a pandas DataFrame.

>>> import pandas as pd
>>> from corruptor import DataFrameCorruptor
>>> df = pd.DataFrame({'firstname': ['frank', 'john'], 'lastname': ['johnson', 'conner']})
>>> dfc = DataFrameCorruptor({'firstname': (0.5, prob), 'lastname': (0.5, prob)})
>>> dfc.corrupt(df, n=2)
  firstname lastname
0     frahk  johnson
1      john   conber

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for corruptor, version 0.3.1
Filename, size & hash File type Python version Upload date
corruptor-0.3.1-py2.py3-none-any.whl (28.4 kB) View hashes Wheel py2.py3
corruptor-0.3.1.tar.gz (27.3 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page