complexifier 0.1.2__tar.gz → 0.2.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.
@@ -0,0 +1,7 @@
1
+ .venv
2
+ venv
3
+ dist
4
+ *.txt
5
+ *.sh
6
+ __pycache__
7
+ testing.py
@@ -0,0 +1,84 @@
1
+ Metadata-Version: 2.3
2
+ Name: complexifier
3
+ Version: 0.2.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
+ 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,7 @@ requires = ["hatchling", "pandas", "shutup", "typo"]
3
3
  build-backend = "hatchling.build"
4
4
  [project]
5
5
  name = "complexifier"
6
- version = "0.1.2"
6
+ version = "0.2.1"
7
7
  authors = [
8
8
  { name="Ruy Zambrano", email="ruyzambrano@gmail.com" },
9
9
  ]
@@ -4,7 +4,14 @@ from typo import StrErrer
4
4
  import pandas as pd
5
5
 
6
6
  def create_spag_error(word: str) -> str:
7
- """Gives a 10% chance to introduce a spag error to a word"""
7
+ """Gives a 10% chance to introduce a spelling error to a word.
8
+
9
+ Args:
10
+ word (str): The original word to potentially alter.
11
+
12
+ Returns:
13
+ str: The original word or a word with a random spelling error.
14
+ """
8
15
  if len(word) < 3:
9
16
  return word
10
17
  error_object = StrErrer(word)
@@ -36,6 +43,15 @@ def create_spag_error(word: str) -> str:
36
43
  return word
37
44
 
38
45
  def introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame:
46
+ """Applies random spelling errors to specified columns in a DataFrame.
47
+
48
+ Args:
49
+ df (pd.DataFrame): The DataFrame to alter.
50
+ columns (list or str, optional): Column names to apply errors to. If not provided, defaults to all string columns.
51
+
52
+ Returns:
53
+ pd.DataFrame: The DataFrame with potential spelling errors introduced.
54
+ """
39
55
  if not columns:
40
56
  columns = df.select_dtypes(include=["string", "object"]).columns
41
57
  elif isinstance(columns, str):
@@ -52,7 +68,15 @@ def introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame:
52
68
  return df
53
69
 
54
70
  def add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame:
55
- """Adds or subtracts a random integer in the columms of between 1% and 10% of the rows"""
71
+ """Adds or subtracts a random integer in columns of between 1% and 10% of the rows.
72
+
73
+ Args:
74
+ df (pd.DataFrame): The DataFrame to modify.
75
+ columns (list or str, optional): Column names to adjust. Defaults to numeric columns if not specified.
76
+
77
+ Returns:
78
+ pd.DataFrame: The DataFrame with outliers added.
79
+ """
56
80
  if not columns:
57
81
  columns = df.select_dtypes(include="number").columns
58
82
  for col in columns:
@@ -71,7 +95,17 @@ def add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame:
71
95
  def add_standard_deviations(
72
96
  df: pd.DataFrame, columns=None, min_std=1, max_std=5
73
97
  ) -> pd.DataFrame:
74
- """Add 1-5 standard deviations for each column"""
98
+ """Adds random deviations to entries in specified numeric columns to simulate data anomalies.
99
+
100
+ Args:
101
+ df (pd.DataFrame): The DataFrame to manipulate.
102
+ columns (list or str, optional): Column names to modify. Defaults to numeric columns if not specified.
103
+ min_std (int): Minimum number of standard deviations to add.
104
+ max_std (int): Maximum number of standard deviations to add.
105
+
106
+ Returns:
107
+ pd.DataFrame: The DataFrame with deviations added.
108
+ """
75
109
  if not columns:
76
110
  columns = df.select_dtypes(include="number").columns
77
111
 
@@ -91,7 +125,15 @@ def add_standard_deviations(
91
125
 
92
126
 
93
127
  def duplicate_rows(df: pd.DataFrame, sample_size=None) -> pd.DataFrame:
94
- """Adds duplicate rows to a dataframe"""
128
+ """Adds duplicate rows to a DataFrame.
129
+
130
+ Args:
131
+ df (pd.DataFrame): DataFrame to which duplicates will be added.
132
+ sample_size (int, optional): Number of rows to duplicate. Randomly selected if not specified.
133
+
134
+ Returns:
135
+ pd.DataFrame: The DataFrame with duplicate rows added.
136
+ """
95
137
  if not sample_size:
96
138
  sample_size = random.randint(len(df[col]) // 100, len(df[col]) // 10)
97
139
  new_rows = df.sample(sample_size)
@@ -101,6 +143,17 @@ def duplicate_rows(df: pd.DataFrame, sample_size=None) -> pd.DataFrame:
101
143
  def add_nulls(
102
144
  df: pd.DataFrame, columns=None, min_percent=1, max_percent=10
103
145
  ) -> pd.DataFrame:
146
+ """Inserts null values into specified DataFrame columns.
147
+
148
+ Args:
149
+ df (pd.DataFrame): The DataFrame to modify.
150
+ columns (list or str, optional): Specific columns to add nulls to. Defaults to all columns if not specified.
151
+ min_percent (int): Minimum percentage of null values to insert.
152
+ max_percent (int): Maximum percentage of null values to insert.
153
+
154
+ Returns:
155
+ pd.DataFrame: The DataFrame with null values inserted.
156
+ """
104
157
  if not columns:
105
158
  columns = df.columns
106
159
  for col in columns:
@@ -1,5 +0,0 @@
1
- .venv
2
- venv
3
- dist
4
- *.txt
5
- *.sh
@@ -1,43 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: complexifier
3
- Version: 0.1.2
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
- `introduce_spag_error`: Each item in your pandas has a 10% chance to receive a random spelling error in the data
39
-
40
- `add_or_subtract_outliers`: Adds
41
- - `add_standard_deviations`
42
- - `duplicate_rows`
43
- - `add_nulls`
@@ -1,30 +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
- `introduce_spag_error`: Each item in your pandas has a 10% chance to receive a random spelling error in the data
26
-
27
- `add_or_subtract_outliers`: Adds
28
- - `add_standard_deviations`
29
- - `duplicate_rows`
30
- - `add_nulls`
@@ -1,16 +0,0 @@
1
- from main import introduce_spag_error
2
- import pandas as pd
3
-
4
- data = pd.DataFrame({
5
- 'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eva'],
6
- 'Age': [28, 34, 29, 42, 25],
7
- 'City': ['New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix'],
8
- 'Salary': [70000, 80000, 72000, 95000, 67000]
9
- })
10
-
11
- for _ in range(10):
12
- data = pd.concat([data, data])
13
-
14
- data = introduce_spag_error(data, columns="City")
15
-
16
- print(data["City"].value_counts())
File without changes