complexifier 0.1.1__tar.gz → 0.1.2__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.1.1
3
+ Version: 0.1.2
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
@@ -15,16 +15,29 @@ Description-Content-Type: text/markdown
15
15
 
16
16
  This makes your pandas dataframe even worse
17
17
 
18
+ ## Dependencies
19
+
20
+ - `pandas`
21
+ - `typo`
22
+ - `random`
23
+
18
24
  ## Installation
19
25
 
26
+ `complexifier` can be installed using `pip`
27
+
20
28
  ```sh
21
29
  pip install complexifier
22
30
  ```
23
31
 
24
32
  ## Usage
25
33
 
26
- `introduce_spag_error`
27
- `add_or_subtract_outliers`
28
- `add_standard_deviations`
29
- `duplicate_rows`
30
- `add_nulls`
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`
@@ -0,0 +1,30 @@
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`
@@ -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.1"
6
+ version = "0.1.2"
7
7
  authors = [
8
8
  { name="Ruy Zambrano", email="ruyzambrano@gmail.com" },
9
9
  ]
@@ -3,7 +3,8 @@ import random
3
3
  from typo import StrErrer
4
4
  import pandas as pd
5
5
 
6
- def introduce_spag_error(word: str) -> str:
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
+
@@ -0,0 +1,16 @@
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())
@@ -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