complexifier 0.1.1__tar.gz → 0.2.0__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.2.0/.gitignore +7 -0
- complexifier-0.2.0/PKG-INFO +84 -0
- complexifier-0.2.0/README.md +71 -0
- {complexifier-0.1.1 → complexifier-0.2.0}/pyproject.toml +1 -1
- {complexifier-0.1.1 → complexifier-0.2.0}/src/complexifier/main.py +18 -1
- complexifier-0.1.1/.gitignore +0 -5
- complexifier-0.1.1/PKG-INFO +0 -30
- complexifier-0.1.1/README.md +0 -17
- {complexifier-0.1.1 → complexifier-0.2.0}/LICENSE +0 -0
- {complexifier-0.1.1 → complexifier-0.2.0}/src/complexifier/__init__.py +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: complexifier
|
|
3
|
+
Version: 0.2.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.
|
|
@@ -0,0 +1,71 @@
|
|
|
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.
|
|
@@ -3,7 +3,8 @@ import random
|
|
|
3
3
|
from typo import StrErrer
|
|
4
4
|
import pandas as pd
|
|
5
5
|
|
|
6
|
-
def
|
|
6
|
+
def create_spag_error(word: str) -> str:
|
|
7
|
+
"""Gives a 10% chance to introduce a spag error to a word"""
|
|
7
8
|
if len(word) < 3:
|
|
8
9
|
return word
|
|
9
10
|
error_object = StrErrer(word)
|
|
@@ -34,6 +35,21 @@ def introduce_spag_error(word: str) -> str:
|
|
|
34
35
|
case _:
|
|
35
36
|
return word
|
|
36
37
|
|
|
38
|
+
def introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame:
|
|
39
|
+
if not columns:
|
|
40
|
+
columns = df.select_dtypes(include=["string", "object"]).columns
|
|
41
|
+
elif isinstance(columns, str):
|
|
42
|
+
columns = [columns]
|
|
43
|
+
|
|
44
|
+
elif not isinstance(columns, list):
|
|
45
|
+
raise TypeError(f"Columns is type {type(columns)} but expected str or list")
|
|
46
|
+
for col in columns:
|
|
47
|
+
if col not in df.columns:
|
|
48
|
+
raise ValueError(f"{col} not in DataFrame")
|
|
49
|
+
if not pd.api.types.is_string_dtype(df[col]):
|
|
50
|
+
raise TypeError(f"{col} is {df[col].dtype}, not a string type")
|
|
51
|
+
df[col] = df[col].apply(create_spag_error)
|
|
52
|
+
return df
|
|
37
53
|
|
|
38
54
|
def add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame:
|
|
39
55
|
"""Adds or subtracts a random integer in the columms of between 1% and 10% of the rows"""
|
|
@@ -93,3 +109,4 @@ def add_nulls(
|
|
|
93
109
|
).index
|
|
94
110
|
df.loc[indices_to_none, col] = None
|
|
95
111
|
return df
|
|
112
|
+
|
complexifier-0.1.1/.gitignore
DELETED
complexifier-0.1.1/PKG-INFO
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: complexifier
|
|
3
|
-
Version: 0.1.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
|
-
## Installation
|
|
19
|
-
|
|
20
|
-
```sh
|
|
21
|
-
pip install complexifier
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Usage
|
|
25
|
-
|
|
26
|
-
`introduce_spag_error`
|
|
27
|
-
`add_or_subtract_outliers`
|
|
28
|
-
`add_standard_deviations`
|
|
29
|
-
`duplicate_rows`
|
|
30
|
-
`add_nulls`
|
complexifier-0.1.1/README.md
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Complexifier
|
|
2
|
-
|
|
3
|
-
This makes your pandas dataframe even worse
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
pip install complexifier
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
`introduce_spag_error`
|
|
14
|
-
`add_or_subtract_outliers`
|
|
15
|
-
`add_standard_deviations`
|
|
16
|
-
`duplicate_rows`
|
|
17
|
-
`add_nulls`
|
|
File without changes
|
|
File without changes
|