complexifier 0.3.0__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- complexifier-0.3.1/PKG-INFO +105 -0
- complexifier-0.3.1/README.md +92 -0
- {complexifier-0.3.0 → complexifier-0.3.1}/pyproject.toml +1 -1
- {complexifier-0.3.0 → complexifier-0.3.1}/src/complexifier/main.py +24 -15
- complexifier-0.3.0/PKG-INFO +0 -84
- complexifier-0.3.0/README.md +0 -71
- {complexifier-0.3.0 → complexifier-0.3.1}/.gitignore +0 -0
- {complexifier-0.3.0 → complexifier-0.3.1}/LICENSE +0 -0
- {complexifier-0.3.0 → complexifier-0.3.1}/src/complexifier/__init__.py +0 -0
- {complexifier-0.3.0 → complexifier-0.3.1}/src/complexifier/test_main.py +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: complexifier
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: A library to make data worse
|
|
5
|
+
Project-URL: Homepage, https://github.com/ruyzambrano/complexifier
|
|
6
|
+
Project-URL: Issues, https://github.com/ruyzambrano/complexifier/issues
|
|
7
|
+
Author-email: Ruy Zambrano <ruyzambrano@gmail.com>
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# Complexifier
|
|
15
|
+
|
|
16
|
+
This makes your pandas dataframe even worse
|
|
17
|
+
|
|
18
|
+
## Dependencies
|
|
19
|
+
|
|
20
|
+
- `pandas`
|
|
21
|
+
- `typo`
|
|
22
|
+
- `random`
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
`complexifier` can be installed using `pip`
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
pip install complexifier
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
Once installed you can use `complexifier` to add mistakes and outliers to your data
|
|
35
|
+
|
|
36
|
+
This library has several methods available:
|
|
37
|
+
|
|
38
|
+
### `create_spag_error(word: str) -> str`
|
|
39
|
+
|
|
40
|
+
**Parameters**:
|
|
41
|
+
- `word` (str): The original word to potentially alter.
|
|
42
|
+
|
|
43
|
+
Introduces a 10% chance of a random spelling error in a given word. This function is useful for simulating typos and spelling mistakes in text data.
|
|
44
|
+
|
|
45
|
+
### `introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame`
|
|
46
|
+
|
|
47
|
+
Applies the create_spag_error function to each string entry in specified columns of a DataFrame, introducing random spelling errors with a 10% probability.
|
|
48
|
+
|
|
49
|
+
**Parameters**:
|
|
50
|
+
- `df` (pd.DataFrame): The DataFrame to alter.
|
|
51
|
+
- `columns` (list or str): Column names to apply errors to. Defaults to all string columns.
|
|
52
|
+
|
|
53
|
+
### `add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame`
|
|
54
|
+
|
|
55
|
+
Randomly adds or subtracts values in specified numeric columns at random indices, simulating outliers between 1% and 10% of the rows.
|
|
56
|
+
|
|
57
|
+
**Parameters**:
|
|
58
|
+
- `df` (pd.DataFrame): The DataFrame to modify.
|
|
59
|
+
- `columns` (list or str): Column names to adjust. Defaults to all numeric columns if not specified.
|
|
60
|
+
|
|
61
|
+
### `add_standard_deviations(df: pd.DataFrame, columns=None, min_std=1, max_std=5) -> pd.DataFrame`
|
|
62
|
+
|
|
63
|
+
Adds between 1 to 5 standard deviations to random entries in specified numeric columns to simulate data anomalies.
|
|
64
|
+
|
|
65
|
+
**Parameters**:
|
|
66
|
+
- `df` (pd.DataFrame): The DataFrame to manipulate.
|
|
67
|
+
- `columns` (list or str): Column names to modify. Defaults to numeric columns if not specified.
|
|
68
|
+
- `min_std` (int): Minimum number of standard deviations to add. Defaults to 1
|
|
69
|
+
- `max_std` (int): Maximum number of standard deviations to add. Defaults to 5
|
|
70
|
+
|
|
71
|
+
### `duplicate_rows(df: pd.DataFrame, sample_size=None) -> pd.DataFrame`
|
|
72
|
+
|
|
73
|
+
Introduces duplicate rows into a DataFrame. This function is useful for testing deduplication processes.
|
|
74
|
+
|
|
75
|
+
**Parameters**:
|
|
76
|
+
- `df` (pd.DataFrame): DataFrame to which duplicates will be added.
|
|
77
|
+
- `sample_size` (int): number of rows to duplicate. A random percentage between 1% and 10% if not specified.
|
|
78
|
+
|
|
79
|
+
### `add_nulls(df: pd.DataFrame, columns=None, min_percent=1, max_percent=10) -> pd.DataFrame`
|
|
80
|
+
|
|
81
|
+
Inserts null values into specified DataFrame columns. This simulates missing data conditions.
|
|
82
|
+
|
|
83
|
+
**Parameters**:
|
|
84
|
+
- `df` (pd.DataFrame): The DataFrame to modify.
|
|
85
|
+
- `columns` (list or str, optional): Specific columns to add nulls to. Defaults to all columns if not specified.
|
|
86
|
+
- `min_percent` (int): Minimum percentage of null values to insert. Defaults to 1%
|
|
87
|
+
- `max_percent` (int): Maximum percentage of null values to insert. Defaults to 10%
|
|
88
|
+
|
|
89
|
+
### `mess_it_up(df: pd.DataFrame, columns=None, min_std=1, max_std=5, sample_size=None,min_percent=1, max_percent=10, introduce_spag=True, add_outliers=True, add_std=True, duplicate=True, add_null=True) -> pd.DataFrame`
|
|
90
|
+
|
|
91
|
+
Adds all (or some) of the above methods. Really messes it up.
|
|
92
|
+
|
|
93
|
+
**Parameters**:
|
|
94
|
+
- `df` (pd.DataFrame): The DataFrame to modify.
|
|
95
|
+
- `columns` (list or str, optional): Specific columns to add nulls to. Defaults to all columns if not specified.
|
|
96
|
+
- `min_std` (int): Minimum number of standard deviations to add. Defaults to 1
|
|
97
|
+
- `max_std` (int): Maximum number of standard deviations to add. Defaults to 5
|
|
98
|
+
- `sample_size` (int, optional): Number of rows to duplicate. Randomly selected if not specified.
|
|
99
|
+
- `min_percent` (int): Minimum percentage of null values to insert. Defaults to 1%
|
|
100
|
+
- `max_percent` (int): Maximum percentage of null values to insert. Defaults to 10%
|
|
101
|
+
- `introduce_spag` (bool): Adds spelling and grammar errors into string data. Defaults to True
|
|
102
|
+
- `add_outliers` (bool): Adds outliers to numerical data. Defaults to True
|
|
103
|
+
- `add_std` (bool): Adds standard deviations to the data. Defaults to True
|
|
104
|
+
- `duplicate` (bool): Adds duplicate rows to the data. Defaults to True
|
|
105
|
+
- `add_null` (bool): Adds null values to the dataset. Defaults to True
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Complexifier
|
|
2
|
+
|
|
3
|
+
This makes your pandas dataframe even worse
|
|
4
|
+
|
|
5
|
+
## Dependencies
|
|
6
|
+
|
|
7
|
+
- `pandas`
|
|
8
|
+
- `typo`
|
|
9
|
+
- `random`
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
`complexifier` can be installed using `pip`
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
pip install complexifier
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
Once installed you can use `complexifier` to add mistakes and outliers to your data
|
|
22
|
+
|
|
23
|
+
This library has several methods available:
|
|
24
|
+
|
|
25
|
+
### `create_spag_error(word: str) -> str`
|
|
26
|
+
|
|
27
|
+
**Parameters**:
|
|
28
|
+
- `word` (str): The original word to potentially alter.
|
|
29
|
+
|
|
30
|
+
Introduces a 10% chance of a random spelling error in a given word. This function is useful for simulating typos and spelling mistakes in text data.
|
|
31
|
+
|
|
32
|
+
### `introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame`
|
|
33
|
+
|
|
34
|
+
Applies the create_spag_error function to each string entry in specified columns of a DataFrame, introducing random spelling errors with a 10% probability.
|
|
35
|
+
|
|
36
|
+
**Parameters**:
|
|
37
|
+
- `df` (pd.DataFrame): The DataFrame to alter.
|
|
38
|
+
- `columns` (list or str): Column names to apply errors to. Defaults to all string columns.
|
|
39
|
+
|
|
40
|
+
### `add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame`
|
|
41
|
+
|
|
42
|
+
Randomly adds or subtracts values in specified numeric columns at random indices, simulating outliers between 1% and 10% of the rows.
|
|
43
|
+
|
|
44
|
+
**Parameters**:
|
|
45
|
+
- `df` (pd.DataFrame): The DataFrame to modify.
|
|
46
|
+
- `columns` (list or str): Column names to adjust. Defaults to all numeric columns if not specified.
|
|
47
|
+
|
|
48
|
+
### `add_standard_deviations(df: pd.DataFrame, columns=None, min_std=1, max_std=5) -> pd.DataFrame`
|
|
49
|
+
|
|
50
|
+
Adds between 1 to 5 standard deviations to random entries in specified numeric columns to simulate data anomalies.
|
|
51
|
+
|
|
52
|
+
**Parameters**:
|
|
53
|
+
- `df` (pd.DataFrame): The DataFrame to manipulate.
|
|
54
|
+
- `columns` (list or str): Column names to modify. Defaults to numeric columns if not specified.
|
|
55
|
+
- `min_std` (int): Minimum number of standard deviations to add. Defaults to 1
|
|
56
|
+
- `max_std` (int): Maximum number of standard deviations to add. Defaults to 5
|
|
57
|
+
|
|
58
|
+
### `duplicate_rows(df: pd.DataFrame, sample_size=None) -> pd.DataFrame`
|
|
59
|
+
|
|
60
|
+
Introduces duplicate rows into a DataFrame. This function is useful for testing deduplication processes.
|
|
61
|
+
|
|
62
|
+
**Parameters**:
|
|
63
|
+
- `df` (pd.DataFrame): DataFrame to which duplicates will be added.
|
|
64
|
+
- `sample_size` (int): number of rows to duplicate. A random percentage between 1% and 10% if not specified.
|
|
65
|
+
|
|
66
|
+
### `add_nulls(df: pd.DataFrame, columns=None, min_percent=1, max_percent=10) -> pd.DataFrame`
|
|
67
|
+
|
|
68
|
+
Inserts null values into specified DataFrame columns. This simulates missing data conditions.
|
|
69
|
+
|
|
70
|
+
**Parameters**:
|
|
71
|
+
- `df` (pd.DataFrame): The DataFrame to modify.
|
|
72
|
+
- `columns` (list or str, optional): Specific columns to add nulls to. Defaults to all columns if not specified.
|
|
73
|
+
- `min_percent` (int): Minimum percentage of null values to insert. Defaults to 1%
|
|
74
|
+
- `max_percent` (int): Maximum percentage of null values to insert. Defaults to 10%
|
|
75
|
+
|
|
76
|
+
### `mess_it_up(df: pd.DataFrame, columns=None, min_std=1, max_std=5, sample_size=None,min_percent=1, max_percent=10, introduce_spag=True, add_outliers=True, add_std=True, duplicate=True, add_null=True) -> pd.DataFrame`
|
|
77
|
+
|
|
78
|
+
Adds all (or some) of the above methods. Really messes it up.
|
|
79
|
+
|
|
80
|
+
**Parameters**:
|
|
81
|
+
- `df` (pd.DataFrame): The DataFrame to modify.
|
|
82
|
+
- `columns` (list or str, optional): Specific columns to add nulls to. Defaults to all columns if not specified.
|
|
83
|
+
- `min_std` (int): Minimum number of standard deviations to add. Defaults to 1
|
|
84
|
+
- `max_std` (int): Maximum number of standard deviations to add. Defaults to 5
|
|
85
|
+
- `sample_size` (int, optional): Number of rows to duplicate. Randomly selected if not specified.
|
|
86
|
+
- `min_percent` (int): Minimum percentage of null values to insert. Defaults to 1%
|
|
87
|
+
- `max_percent` (int): Maximum percentage of null values to insert. Defaults to 10%
|
|
88
|
+
- `introduce_spag` (bool): Adds spelling and grammar errors into string data. Defaults to True
|
|
89
|
+
- `add_outliers` (bool): Adds outliers to numerical data. Defaults to True
|
|
90
|
+
- `add_std` (bool): Adds standard deviations to the data. Defaults to True
|
|
91
|
+
- `duplicate` (bool): Adds duplicate rows to the data. Defaults to True
|
|
92
|
+
- `add_null` (bool): Adds null values to the dataset. Defaults to True
|
|
@@ -49,7 +49,7 @@ def introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame:
|
|
|
49
49
|
|
|
50
50
|
Args:
|
|
51
51
|
df (pd.DataFrame): The DataFrame to alter.
|
|
52
|
-
columns (list or str
|
|
52
|
+
columns (list or str): Column names to apply errors to. Defaults to all string columns.
|
|
53
53
|
|
|
54
54
|
Returns:
|
|
55
55
|
pd.DataFrame: The DataFrame with potential spelling errors introduced.
|
|
@@ -79,7 +79,7 @@ def add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame:
|
|
|
79
79
|
|
|
80
80
|
Args:
|
|
81
81
|
df (pd.DataFrame): The DataFrame to modify.
|
|
82
|
-
columns (list or str
|
|
82
|
+
columns (list or str): Column names to adjust. Defaults to all numeric columns if not specified.
|
|
83
83
|
|
|
84
84
|
Returns:
|
|
85
85
|
pd.DataFrame: The DataFrame with outliers added.
|
|
@@ -120,9 +120,9 @@ def add_standard_deviations(
|
|
|
120
120
|
|
|
121
121
|
Args:
|
|
122
122
|
df (pd.DataFrame): The DataFrame to manipulate.
|
|
123
|
-
columns (list or str
|
|
124
|
-
min_std (int): Minimum number of standard deviations to add.
|
|
125
|
-
max_std (int): Maximum number of standard deviations to add.
|
|
123
|
+
columns (list or str): Column names to modify. Defaults to numeric columns if not specified.
|
|
124
|
+
min_std (int): Minimum number of standard deviations to add. Defaults to 1
|
|
125
|
+
max_std (int): Maximum number of standard deviations to add. Defaults to 5
|
|
126
126
|
|
|
127
127
|
Returns:
|
|
128
128
|
pd.DataFrame: The DataFrame with deviations added.
|
|
@@ -158,7 +158,7 @@ def duplicate_rows(df: pd.DataFrame, sample_size=None) -> pd.DataFrame:
|
|
|
158
158
|
|
|
159
159
|
Args:
|
|
160
160
|
df (pd.DataFrame): DataFrame to which duplicates will be added.
|
|
161
|
-
sample_size (int
|
|
161
|
+
sample_size (int): number of rows to duplicate. A random percentage between 1% and 10% if not specified.
|
|
162
162
|
|
|
163
163
|
Returns:
|
|
164
164
|
pd.DataFrame: The DataFrame with duplicate rows added.
|
|
@@ -223,7 +223,7 @@ def mess_it_up(
|
|
|
223
223
|
add_outliers=True,
|
|
224
224
|
add_std=True,
|
|
225
225
|
duplicate=True,
|
|
226
|
-
add_null=True
|
|
226
|
+
add_null=True
|
|
227
227
|
) -> pd.DataFrame:
|
|
228
228
|
"""
|
|
229
229
|
Applies several functions to add outliers, spelling errors and null values
|
|
@@ -236,6 +236,11 @@ def mess_it_up(
|
|
|
236
236
|
sample_size (int, optional): Number of rows to duplicate. Randomly selected if not specified.
|
|
237
237
|
min_percent (int): Minimum percentage of null values to insert. Defaults to 1%
|
|
238
238
|
max_percent (int): Maximum percentage of null values to insert. Defaults to 10%
|
|
239
|
+
introduce_spag (bool): Adds spelling and grammar errors into string data. Defaults to True
|
|
240
|
+
add_outliers (bool): Adds outliers to numerical data. Defaults to True
|
|
241
|
+
add_std (bool): Adds standard deviations to the data. Defaults to True
|
|
242
|
+
duplicate (bool): Adds duplicate rows to the data. Defaults to True
|
|
243
|
+
add_null (bool): Adds null values to the dataset. Defaults to True
|
|
239
244
|
|
|
240
245
|
"""
|
|
241
246
|
if not isinstance(df, pd.DataFrame):
|
|
@@ -254,15 +259,19 @@ def mess_it_up(
|
|
|
254
259
|
string_cols = df[columns].select_dtypes(include="string").columns.to_list()
|
|
255
260
|
numeric_cols = df[columns].select_dtypes(include="number").columns.to_list()
|
|
256
261
|
if string_cols:
|
|
257
|
-
|
|
262
|
+
if introduce_spag:
|
|
263
|
+
df = introduce_spag_error(df, string_cols)
|
|
258
264
|
if numeric_cols:
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
265
|
+
if add_outliers:
|
|
266
|
+
df = add_or_subtract_outliers(df, numeric_cols)
|
|
267
|
+
if add_std:
|
|
268
|
+
df = add_standard_deviations(
|
|
269
|
+
df, numeric_cols, min_std, max_std
|
|
270
|
+
)
|
|
271
|
+
if duplicate:
|
|
272
|
+
df = duplicate_rows(df, sample_size)
|
|
273
|
+
if add_null:
|
|
274
|
+
df = add_nulls(df, columns, min_percent, max_percent)
|
|
266
275
|
return df
|
|
267
276
|
|
|
268
277
|
|
complexifier-0.3.0/PKG-INFO
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: complexifier
|
|
3
|
-
Version: 0.3.0
|
|
4
|
-
Summary: A library to make data worse
|
|
5
|
-
Project-URL: Homepage, https://github.com/ruyzambrano/complexifier
|
|
6
|
-
Project-URL: Issues, https://github.com/ruyzambrano/complexifier/issues
|
|
7
|
-
Author-email: Ruy Zambrano <ruyzambrano@gmail.com>
|
|
8
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
-
Classifier: Operating System :: OS Independent
|
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Requires-Python: >=3.8
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
|
|
14
|
-
# Complexifier
|
|
15
|
-
|
|
16
|
-
This makes your pandas dataframe even worse
|
|
17
|
-
|
|
18
|
-
## Dependencies
|
|
19
|
-
|
|
20
|
-
- `pandas`
|
|
21
|
-
- `typo`
|
|
22
|
-
- `random`
|
|
23
|
-
|
|
24
|
-
## Installation
|
|
25
|
-
|
|
26
|
-
`complexifier` can be installed using `pip`
|
|
27
|
-
|
|
28
|
-
```sh
|
|
29
|
-
pip install complexifier
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Usage
|
|
33
|
-
|
|
34
|
-
Once installed you can use `complexifier` to add mistakes and outliers to your data
|
|
35
|
-
|
|
36
|
-
This library has several methods available:
|
|
37
|
-
|
|
38
|
-
### `create_spag_error(word: str) -> str`
|
|
39
|
-
|
|
40
|
-
Introduces a 10% chance of a random spelling error in a given word. This function is useful for simulating typos and spelling mistakes in text data.
|
|
41
|
-
|
|
42
|
-
### `introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame`
|
|
43
|
-
|
|
44
|
-
Applies the create_spag_error function to each string entry in specified columns of a DataFrame, introducing random spelling errors with a 10% probability.
|
|
45
|
-
|
|
46
|
-
**Parameters**:
|
|
47
|
-
- `df`: The DataFrame to be altered.
|
|
48
|
-
- `columns`: Optional; specify column names to apply errors to. If not provided, it defaults to all string columns.
|
|
49
|
-
|
|
50
|
-
### `add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame`
|
|
51
|
-
|
|
52
|
-
Randomly adds or subtracts values in specified numeric columns at random indices, simulating outliers between 1% and 10% of the rows.
|
|
53
|
-
|
|
54
|
-
**Parameters**:
|
|
55
|
-
- `df`: DataFrame to be modified.
|
|
56
|
-
- `columns`: Optional; specify columns to adjust.
|
|
57
|
-
|
|
58
|
-
### `add_standard_deviations(df: pd.DataFrame, columns=None, min_std=1, max_std=5) -> pd.DataFrame`
|
|
59
|
-
|
|
60
|
-
Adds between 1 to 5 standard deviations to random entries in specified numeric columns to simulate data anomalies.
|
|
61
|
-
|
|
62
|
-
**Parameters**:
|
|
63
|
-
- `df`: The DataFrame to manipulate.
|
|
64
|
-
- `columns`: Optional; specify columns to modify.
|
|
65
|
-
- `min_std`: Minimum number of standard deviations to add.
|
|
66
|
-
- `max_std`: Maximum number of standard deviations to add.
|
|
67
|
-
|
|
68
|
-
### `duplicate_rows(df: pd.DataFrame, sample_size=None) -> pd.DataFrame`
|
|
69
|
-
|
|
70
|
-
Introduces duplicate rows into a DataFrame. This function is useful for testing deduplication processes.
|
|
71
|
-
|
|
72
|
-
**Parameters**:
|
|
73
|
-
- `df`: DataFrame where duplicates will be introduced.
|
|
74
|
-
- `sample_size`: Optional; number of rows to duplicate. A random percentage between 1% and 10% if not specified.
|
|
75
|
-
|
|
76
|
-
### `add_nulls(df: pd.DataFrame, columns=None, min_percent=1, max_percent=10) -> pd.DataFrame`
|
|
77
|
-
|
|
78
|
-
Inserts null values into specified DataFrame columns. This simulates missing data conditions.
|
|
79
|
-
|
|
80
|
-
**Parameters**:
|
|
81
|
-
- `df`: The DataFrame to modify.
|
|
82
|
-
- `columns`: Optional; specific columns to add `nulls` to.
|
|
83
|
-
- `min_percent`: Minimum percentage of `null` values to insert.
|
|
84
|
-
- `max_percent`: Maximum percentage of `null` values to insert.
|
complexifier-0.3.0/README.md
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# Complexifier
|
|
2
|
-
|
|
3
|
-
This makes your pandas dataframe even worse
|
|
4
|
-
|
|
5
|
-
## Dependencies
|
|
6
|
-
|
|
7
|
-
- `pandas`
|
|
8
|
-
- `typo`
|
|
9
|
-
- `random`
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
`complexifier` can be installed using `pip`
|
|
14
|
-
|
|
15
|
-
```sh
|
|
16
|
-
pip install complexifier
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Usage
|
|
20
|
-
|
|
21
|
-
Once installed you can use `complexifier` to add mistakes and outliers to your data
|
|
22
|
-
|
|
23
|
-
This library has several methods available:
|
|
24
|
-
|
|
25
|
-
### `create_spag_error(word: str) -> str`
|
|
26
|
-
|
|
27
|
-
Introduces a 10% chance of a random spelling error in a given word. This function is useful for simulating typos and spelling mistakes in text data.
|
|
28
|
-
|
|
29
|
-
### `introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame`
|
|
30
|
-
|
|
31
|
-
Applies the create_spag_error function to each string entry in specified columns of a DataFrame, introducing random spelling errors with a 10% probability.
|
|
32
|
-
|
|
33
|
-
**Parameters**:
|
|
34
|
-
- `df`: The DataFrame to be altered.
|
|
35
|
-
- `columns`: Optional; specify column names to apply errors to. If not provided, it defaults to all string columns.
|
|
36
|
-
|
|
37
|
-
### `add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame`
|
|
38
|
-
|
|
39
|
-
Randomly adds or subtracts values in specified numeric columns at random indices, simulating outliers between 1% and 10% of the rows.
|
|
40
|
-
|
|
41
|
-
**Parameters**:
|
|
42
|
-
- `df`: DataFrame to be modified.
|
|
43
|
-
- `columns`: Optional; specify columns to adjust.
|
|
44
|
-
|
|
45
|
-
### `add_standard_deviations(df: pd.DataFrame, columns=None, min_std=1, max_std=5) -> pd.DataFrame`
|
|
46
|
-
|
|
47
|
-
Adds between 1 to 5 standard deviations to random entries in specified numeric columns to simulate data anomalies.
|
|
48
|
-
|
|
49
|
-
**Parameters**:
|
|
50
|
-
- `df`: The DataFrame to manipulate.
|
|
51
|
-
- `columns`: Optional; specify columns to modify.
|
|
52
|
-
- `min_std`: Minimum number of standard deviations to add.
|
|
53
|
-
- `max_std`: Maximum number of standard deviations to add.
|
|
54
|
-
|
|
55
|
-
### `duplicate_rows(df: pd.DataFrame, sample_size=None) -> pd.DataFrame`
|
|
56
|
-
|
|
57
|
-
Introduces duplicate rows into a DataFrame. This function is useful for testing deduplication processes.
|
|
58
|
-
|
|
59
|
-
**Parameters**:
|
|
60
|
-
- `df`: DataFrame where duplicates will be introduced.
|
|
61
|
-
- `sample_size`: Optional; number of rows to duplicate. A random percentage between 1% and 10% if not specified.
|
|
62
|
-
|
|
63
|
-
### `add_nulls(df: pd.DataFrame, columns=None, min_percent=1, max_percent=10) -> pd.DataFrame`
|
|
64
|
-
|
|
65
|
-
Inserts null values into specified DataFrame columns. This simulates missing data conditions.
|
|
66
|
-
|
|
67
|
-
**Parameters**:
|
|
68
|
-
- `df`: The DataFrame to modify.
|
|
69
|
-
- `columns`: Optional; specific columns to add `nulls` to.
|
|
70
|
-
- `min_percent`: Minimum percentage of `null` values to insert.
|
|
71
|
-
- `max_percent`: Maximum percentage of `null` values to insert.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|