complexifier 0.2.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: complexifier
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A library to make data worse
5
5
  Project-URL: Homepage, https://github.com/ruyzambrano/complexifier
6
6
  Project-URL: Issues, https://github.com/ruyzambrano/complexifier/issues
@@ -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.2.0"
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:
File without changes
File without changes
File without changes