complexifier 0.0.4__py3-none-any.whl

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 @@
1
+ from main import *
complexifier/main.py ADDED
@@ -0,0 +1,95 @@
1
+ import random
2
+
3
+ from typo import StrErrer
4
+ import pandas as pd
5
+
6
+ def introduce_spag_error(word: str) -> str:
7
+ if len(word) < 3:
8
+ return word
9
+ error_object = StrErrer(word)
10
+ weight = random.randint(1, 100)
11
+ match weight:
12
+ case 1:
13
+ return error_object.missing_char()
14
+ case 2:
15
+ return error_object.char_swap()
16
+ case 3:
17
+ return error_object.extra_char()
18
+ case 4:
19
+ return error_object.nearby_char()
20
+ case 5:
21
+ return error_object.similar_char()
22
+ case 6:
23
+ return error_object.random_space()
24
+ case 7:
25
+ return error_object.repeated_char()
26
+ case 8:
27
+ return word.lower()
28
+ case 9:
29
+ return word.upper()
30
+ case 10:
31
+ return "".join(
32
+ [char.upper() if random.randint(0, 100) < 10 else char for char in word]
33
+ )
34
+ case _:
35
+ return word
36
+
37
+
38
+ def add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame:
39
+ """Adds or subtracts a random integer in the columms of between 1% and 10% of the rows"""
40
+ if not columns:
41
+ columns = df.select_dtypes(include="number").columns
42
+ for col in columns:
43
+ if col not in df.columns:
44
+ raise ValueError(f"{col} is not a column.")
45
+ data_range = round(df[col].max() - df[col].min())
46
+ random_indices = df.sample(
47
+ random.randint(len(df[col] // 100), len(df[col] // 10))
48
+ ).index
49
+ df.loc[random_indices, col] = df.loc[random_indices, col].apply(
50
+ lambda row: row + random.randint(-2 * data_range, 2 * data_range)
51
+ )
52
+ return df
53
+
54
+
55
+ def add_standard_deviations(
56
+ df: pd.DataFrame, columns=None, min_std=1, max_std=5
57
+ ) -> pd.DataFrame:
58
+ """Add 1-5 standard deviations for each column"""
59
+ if not columns:
60
+ columns = df.select_dtypes(include="number").columns
61
+
62
+ for col in columns:
63
+ if col not in df.columns:
64
+ raise ValueError(f"{col} is not a column.")
65
+ sample_size = random.randint(len(df[col]) // 100, len(df[col]) // 10)
66
+ standard_deviation = df[col].std()
67
+ random_indices = df.sample(sample_size).index
68
+ df.loc[random_indices, col] = df.loc[random_indices, col].apply(
69
+ lambda row: row
70
+ + random.randint(min_std, max_std)
71
+ * standard_deviation
72
+ * random.choice([1, -1])
73
+ )
74
+ return df
75
+
76
+
77
+ def duplicate_rows(df: pd.DataFrame, sample_size=None) -> pd.DataFrame:
78
+ """Adds duplicate rows to a dataframe"""
79
+ if not sample_size:
80
+ sample_size = random.randint(len(df[col]) // 100, len(df[col]) // 10)
81
+ new_rows = df.sample(sample_size)
82
+ return pd.concat([df, new_rows])
83
+
84
+
85
+ def add_nulls(
86
+ df: pd.DataFrame, columns=None, min_percent=1, max_percent=10
87
+ ) -> pd.DataFrame:
88
+ if not columns:
89
+ columns = df.columns
90
+ for col in columns:
91
+ indices_to_none = df.sample(
92
+ len(df) * random.randint(min_percent, max_percent) // 100
93
+ ).index
94
+ df.loc[indices_to_none, col] = None
95
+ return df
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.3
2
+ Name: complexifier
3
+ Version: 0.0.4
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
@@ -0,0 +1,6 @@
1
+ complexifier/__init__.py,sha256=5BbKQVb39kq2EZbTiPeOsMrtqdLGHeasWhCxn064NtU,18
2
+ complexifier/main.py,sha256=iCarZGDydZIQ41Ogm0xaIqRizsh2F6ifZcv78iCEJu4,3104
3
+ complexifier-0.0.4.dist-info/METADATA,sha256=GnyCxkCLdcriHbLnl37d9zRGgYO9INtpti8h4kK_Wnw,554
4
+ complexifier-0.0.4.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
5
+ complexifier-0.0.4.dist-info/licenses/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
6
+ complexifier-0.0.4.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.26.3
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2018 The Python Packaging Authority
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.