complexifier 0.3.0__tar.gz → 0.3.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.
@@ -0,0 +1,32 @@
1
+ name: Test Library
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - '**'
7
+ pull_request:
8
+ branches:
9
+ - main
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - name: Checkout code
17
+ uses: actions/checkout@v3
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v4
21
+ with:
22
+ python-version: '3.x'
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install -r requirements.txt
28
+
29
+ - name: Run tests with coverage
30
+ run: |
31
+ pytest --cov=complexifier
32
+
@@ -0,0 +1,26 @@
1
+ name: "Sphinx: Render docs"
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ permissions:
9
+ contents: write
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ with:
13
+ persist-credentials: false
14
+ - name: Build HTML
15
+ uses: ammaraskar/sphinx-action@master
16
+ - name: Upload artifacts
17
+ uses: actions/upload-artifact@v4
18
+ with:
19
+ name: html-docs
20
+ path: docs/build/html/
21
+ - name: Deploy
22
+ uses: peaceiris/actions-gh-pages@v3
23
+ if: github.ref == 'refs/heads/main'
24
+ with:
25
+ github_token: ${{ secrets.GITHUB_TOKEN }}
26
+ publish_dir: docs/build/html
@@ -5,4 +5,6 @@ dist
5
5
  *.sh
6
6
  __pycache__
7
7
  testing.py
8
- .coverage
8
+ .coverage
9
+ .pytest_cache
10
+ docs/build
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: complexifier
3
- Version: 0.3.0
3
+ Version: 0.3.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
@@ -13,7 +13,18 @@ Description-Content-Type: text/markdown
13
13
 
14
14
  # Complexifier
15
15
 
16
- This makes your pandas dataframe even worse
16
+ Make your pandas even worse!
17
+
18
+ ## Problem
19
+
20
+ When teaching students to work with data, an important lesson is how to clean it.
21
+
22
+ The problem with this is that there are two types of datasets available on the internet:
23
+
24
+ 1. Data that is good, but already cleaned
25
+ 2. Data that is not cleaned, but is terrible and incomprehensible
26
+
27
+ Complexifier solves this problem by allowing you take the former and turn it into a better version of the latter!
17
28
 
18
29
  ## Dependencies
19
30
 
@@ -31,54 +42,50 @@ pip install complexifier
31
42
 
32
43
  ## Usage
33
44
 
45
+ [Go to the documentation](https://ruyzambrano.github.io/complexifier/)
46
+
34
47
  Once installed you can use `complexifier` to add mistakes and outliers to your data
35
48
 
36
49
  This library has several methods available:
37
50
 
38
- ### `create_spag_error(word: str) -> str`
51
+ ### create_spag_error
52
+
53
+ `create_spag_error(word: str) -> str`
39
54
 
40
55
  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
56
 
42
- ### `introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame`
57
+ ### introduce_spag_error
58
+
59
+ `introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame`
43
60
 
44
61
  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
62
 
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.
63
+ ### add_or_subtract_outliers
49
64
 
50
- ### `add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame`
65
+ `add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame`
51
66
 
52
67
  Randomly adds or subtracts values in specified numeric columns at random indices, simulating outliers between 1% and 10% of the rows.
53
68
 
54
- **Parameters**:
55
- - `df`: DataFrame to be modified.
56
- - `columns`: Optional; specify columns to adjust.
69
+ ### add_standard_deviations
57
70
 
58
- ### `add_standard_deviations(df: pd.DataFrame, columns=None, min_std=1, max_std=5) -> pd.DataFrame`
71
+ `add_standard_deviations(df: pd.DataFrame, columns=None, min_std=1, max_std=5) -> pd.DataFrame`
59
72
 
60
73
  Adds between 1 to 5 standard deviations to random entries in specified numeric columns to simulate data anomalies.
61
74
 
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.
75
+ ### duplicate_rows
67
76
 
68
- ### `duplicate_rows(df: pd.DataFrame, sample_size=None) -> pd.DataFrame`
77
+ `duplicate_rows(df: pd.DataFrame, sample_size=None) -> pd.DataFrame`
69
78
 
70
79
  Introduces duplicate rows into a DataFrame. This function is useful for testing deduplication processes.
71
80
 
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.
81
+ ### add_nulls
75
82
 
76
- ### `add_nulls(df: pd.DataFrame, columns=None, min_percent=1, max_percent=10) -> pd.DataFrame`
83
+ `add_nulls(df: pd.DataFrame, columns=None, min_percent=1, max_percent=10) -> pd.DataFrame`
77
84
 
78
85
  Inserts null values into specified DataFrame columns. This simulates missing data conditions.
79
86
 
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.
87
+ ### mess_it_up
88
+
89
+ `mess_it_up(df: pd.DataFrame, columns=None, min_std=1, max_std=5, sample_size=None,min_percent=1, max_percent=10, introduce_spag=True, add_outliers=True, add_std=True, duplicate=True, add_null=True) -> pd.DataFrame`
90
+
91
+ Adds all (or some) of the above methods. Really messes it up.
@@ -0,0 +1,78 @@
1
+ # Complexifier
2
+
3
+ Make your pandas even worse!
4
+
5
+ ## Problem
6
+
7
+ When teaching students to work with data, an important lesson is how to clean it.
8
+
9
+ The problem with this is that there are two types of datasets available on the internet:
10
+
11
+ 1. Data that is good, but already cleaned
12
+ 2. Data that is not cleaned, but is terrible and incomprehensible
13
+
14
+ Complexifier solves this problem by allowing you take the former and turn it into a better version of the latter!
15
+
16
+ ## Dependencies
17
+
18
+ - `pandas`
19
+ - `typo`
20
+ - `random`
21
+
22
+ ## Installation
23
+
24
+ `complexifier` can be installed using `pip`
25
+
26
+ ```sh
27
+ pip install complexifier
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ [Go to the documentation](https://ruyzambrano.github.io/complexifier/)
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
39
+
40
+ `create_spag_error(word: str) -> str`
41
+
42
+ 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.
43
+
44
+ ### introduce_spag_error
45
+
46
+ `introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame`
47
+
48
+ Applies the create_spag_error function to each string entry in specified columns of a DataFrame, introducing random spelling errors with a 10% probability.
49
+
50
+ ### add_or_subtract_outliers
51
+
52
+ `add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame`
53
+
54
+ Randomly adds or subtracts values in specified numeric columns at random indices, simulating outliers between 1% and 10% of the rows.
55
+
56
+ ### add_standard_deviations
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
+ ### duplicate_rows
63
+
64
+ `duplicate_rows(df: pd.DataFrame, sample_size=None) -> pd.DataFrame`
65
+
66
+ Introduces duplicate rows into a DataFrame. This function is useful for testing deduplication processes.
67
+
68
+ ### add_nulls
69
+
70
+ `add_nulls(df: pd.DataFrame, columns=None, min_percent=1, max_percent=10) -> pd.DataFrame`
71
+
72
+ Inserts null values into specified DataFrame columns. This simulates missing data conditions.
73
+
74
+ ### mess_it_up
75
+
76
+ `mess_it_up(df: pd.DataFrame, columns=None, min_std=1, max_std=5, sample_size=None,min_percent=1, max_percent=10, introduce_spag=True, add_outliers=True, add_std=True, duplicate=True, add_null=True) -> pd.DataFrame`
77
+
78
+ Adds all (or some) of the above methods. Really messes it up.
@@ -0,0 +1,182 @@
1
+ Complexifier
2
+ =============
3
+
4
+ Make your pandas even worse!
5
+
6
+ Complexifier is a Python library crafted to transform clean datasets into messy versions by introducing random errors and anomalies. This is particularly useful for educational purposes, where students learn to clean data through practical experience.
7
+
8
+ Problem
9
+ -------
10
+
11
+ When teaching students to work with data, an important lesson is how to clean it.
12
+
13
+ The problem with this is that there are two types of datasets available on the internet:
14
+
15
+ 1. Data that is good, but already cleaned
16
+ 2. Data that is not cleaned, but is terrible and incomprehensible
17
+
18
+ Complexifier solves this problem by allowing you to take the former and turn it into a better version of the latter!
19
+
20
+ Dependencies
21
+ ------------
22
+
23
+ Complexifier relies on the following packages:
24
+
25
+ - `pandas`
26
+ - `typo`
27
+ - `random`
28
+
29
+ Ensure these dependencies are installed in your environment.
30
+
31
+ Installation
32
+ ------------
33
+
34
+ You can install `complexifier` via `pip`:
35
+
36
+ .. code-block:: sh
37
+
38
+ pip install complexifier
39
+
40
+ Usage
41
+ -----
42
+
43
+ Once installed, use `complexifier` to add mistakes and simulate anomalies in your data. This library provides several methods:
44
+
45
+ Methods
46
+ -------
47
+
48
+ create_spag_error
49
+ ~~~~~~~~~~~~~~~~~
50
+
51
+ .. code-block:: python
52
+
53
+ create_spag_error(word: str) -> str
54
+
55
+ Introduces a 10% chance of a random spelling error in a given word, helpful for simulating typos.
56
+
57
+ **Parameters**:
58
+ - `word` (str): The original word to potentially alter.
59
+
60
+ introduce_spag_error
61
+ ~~~~~~~~~~~~~~~~~~~~
62
+
63
+ .. code-block:: python
64
+
65
+ introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame
66
+
67
+ Applies `create_spag_error` to each string entry in specified DataFrame columns, introducing random spelling errors with a 10% probability.
68
+
69
+ **Parameters**:
70
+ - `df` (pd.DataFrame): The DataFrame to alter.
71
+ - `columns` (list or str): Column names to apply errors to. Defaults to all string columns.
72
+
73
+ add_or_subtract_outliers
74
+ ~~~~~~~~~~~~~~~~~~~~~~~~
75
+
76
+ .. code-block:: python
77
+
78
+ add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame
79
+
80
+ Randomly adds or subtracts values in specified numeric columns, simulating outliers in 1% to 10% of rows.
81
+
82
+ **Parameters**:
83
+ - `df` (pd.DataFrame): The DataFrame to modify.
84
+ - `columns` (list or str): Column names to adjust. Defaults to all numeric columns if not specified.
85
+
86
+ add_standard_deviations
87
+ ~~~~~~~~~~~~~~~~~~~~~~~
88
+
89
+ .. code-block:: python
90
+
91
+ add_standard_deviations(df: pd.DataFrame, columns=None, min_std=1, max_std=5) -> pd.DataFrame
92
+
93
+ Adds between 1 to 5 standard deviations to random entries in numeric columns to simulate data anomalies.
94
+
95
+ **Parameters**:
96
+ - `df` (pd.DataFrame): The DataFrame to manipulate.
97
+ - `columns` (list or str): Column names to modify. Defaults to numeric columns if not specified.
98
+ - `min_std` (int): Minimum number of standard deviations to add. Defaults to 1.
99
+ - `max_std` (int): Maximum number of standard deviations to add. Defaults to 5.
100
+
101
+ duplicate_rows
102
+ ~~~~~~~~~~~~~~
103
+
104
+ .. code-block:: python
105
+
106
+ duplicate_rows(df: pd.DataFrame, sample_size=None) -> pd.DataFrame
107
+
108
+ Introduces duplicate rows into a DataFrame, useful for testing deduplication processes.
109
+
110
+ **Parameters**:
111
+ - `df` (pd.DataFrame): DataFrame to which duplicates will be added.
112
+ - `sample_size` (int): Number of rows to duplicate. A random percentage between 1% and 10% if not specified.
113
+
114
+ add_nulls
115
+ ~~~~~~~~~
116
+
117
+ .. code-block:: python
118
+
119
+ add_nulls(df: pd.DataFrame, columns=None, min_percent=1, max_percent=10) -> pd.DataFrame
120
+
121
+ Inserts null values into specified DataFrame columns, simulating missing data conditions.
122
+
123
+ **Parameters**:
124
+ - `df` (pd.DataFrame): The DataFrame to modify.
125
+ - `columns` (list or str, optional): Specific columns to add nulls to. Defaults to all columns if not specified.
126
+ - `min_percent` (int): Minimum percentage of null values to insert. Defaults to 1%.
127
+ - `max_percent` (int): Maximum percentage of null values to insert. Defaults to 10%.
128
+
129
+ mess_it_up
130
+ ~~~~~~~~~~
131
+
132
+ .. code-block:: python
133
+
134
+ mess_it_up(df: pd.DataFrame, columns=None, min_std=1, max_std=5, sample_size=None, min_percent=1, max_percent=10,
135
+ introduce_spag=True, add_outliers=True, add_std=True, duplicate=True, add_null=True) -> pd.DataFrame
136
+
137
+ Integrates all methods to add errors comprehensively to the DataFrame.
138
+
139
+ **Parameters**:
140
+ - `df` (pd.DataFrame): The DataFrame to modify.
141
+ - `columns` (list or str, optional): Specific columns to add nulls to. Defaults to all columns if not specified.
142
+ - `min_std` (int): Minimum number of standard deviations to add. Defaults to 1.
143
+ - `max_std` (int): Maximum number of standard deviations to add. Defaults to 5.
144
+ - `sample_size` (int, optional): Number of rows to duplicate. Randomly selected if not specified.
145
+ - `min_percent` (int): Minimum percentage of null values to insert. Defaults to 1%.
146
+ - `max_percent` (int): Maximum percentage of null values to insert. Defaults to 10%.
147
+ - `introduce_spag` (bool): Adds spelling and grammar errors into string data. Defaults to True.
148
+ - `add_outliers` (bool): Adds outliers to numerical data. Defaults to True.
149
+ - `add_std` (bool): Adds standard deviations to the data. Defaults to True.
150
+ - `duplicate` (bool): Adds duplicate rows to the data. Defaults to True.
151
+ - `add_null` (bool): Adds null values to the dataset. Defaults to True.
152
+
153
+ Contributing
154
+ ------------
155
+
156
+ Feel free to contribute by submitting a pull request on GitHub. For large changes, please open an issue to discuss before implementing changes.
157
+
158
+ License
159
+ -------
160
+
161
+ This project is licensed under the MIT License. See the LICENSE file for details.
162
+
163
+ Contact Information
164
+ -------------------
165
+
166
+ For support or inquiries, please contact the maintainer at maintainer@example.com.
167
+
168
+ Changelog
169
+ ---------
170
+
171
+ ### Version 1.0
172
+
173
+ - Initial release with functionality covering typos, outliers, duplicate rows, and null values.
174
+
175
+ Badges
176
+ ------
177
+
178
+ .. image:: https://img.shields.io/badge/build-passing-brightgreen
179
+ :target: https://github.com/yourusername/complexifier
180
+
181
+ .. image:: https://img.shields.io/badge/coverage-95%25-green
182
+ :target: https://codecov.io/gh/yourusername/complexifier
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = source
9
+ BUILDDIR = build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,35 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=source
11
+ set BUILDDIR=build
12
+
13
+ %SPHINXBUILD% >NUL 2>NUL
14
+ if errorlevel 9009 (
15
+ echo.
16
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17
+ echo.installed, then set the SPHINXBUILD environment variable to point
18
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
19
+ echo.may add the Sphinx directory to PATH.
20
+ echo.
21
+ echo.If you don't have Sphinx installed, grab it from
22
+ echo.https://www.sphinx-doc.org/
23
+ exit /b 1
24
+ )
25
+
26
+ if "%1" == "" goto help
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd
@@ -0,0 +1,28 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # For the full list of built-in configuration values, see the documentation:
4
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
5
+
6
+ # -- Project information -----------------------------------------------------
7
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8
+
9
+ project = 'Complexifier'
10
+ copyright = '2024, Ruy Zambrano'
11
+ author = 'Ruy Zambrano'
12
+ release = '0.3.1'
13
+
14
+ # -- General configuration ---------------------------------------------------
15
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
16
+
17
+ extensions = []
18
+
19
+ templates_path = ['_templates']
20
+ exclude_patterns = []
21
+
22
+
23
+
24
+ # -- Options for HTML output -------------------------------------------------
25
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
26
+
27
+ html_theme = 'groundwork'
28
+ html_static_path = ['_static']
@@ -0,0 +1,207 @@
1
+ Complexifier
2
+ =============
3
+
4
+ Make your pandas even worse!
5
+
6
+ Complexifier is a Python library crafted to transform clean datasets into messy versions by introducing random errors and anomalies. This is particularly useful for educational purposes, where students learn to clean data through practical experience.
7
+
8
+ Problem
9
+ -------
10
+
11
+ When teaching students to work with data, an important lesson is how to clean it.
12
+
13
+ The problem with this is that there are two types of datasets available on the internet:
14
+
15
+ 1. Data that is good, but already cleaned
16
+ 2. Data that is not cleaned, but is terrible and incomprehensible
17
+
18
+ Complexifier solves this problem by allowing you to take the former and turn it into a better version of the latter!
19
+
20
+ Dependencies
21
+ ------------
22
+
23
+ Complexifier relies on the following packages:
24
+
25
+ - `pandas`
26
+ - `typo`
27
+ - `random`
28
+
29
+ Ensure these dependencies are installed in your environment.
30
+
31
+ Installation
32
+ ------------
33
+
34
+ You can install `complexifier` via `pip`:
35
+
36
+ .. code-block:: sh
37
+
38
+ pip install complexifier
39
+
40
+ Usage
41
+ -----
42
+
43
+ Once installed, use `complexifier` to add mistakes and simulate anomalies in your data. This library provides several methods:
44
+
45
+ Methods
46
+ -------
47
+
48
+ create_spag_error
49
+ ~~~~~~~~~~~~~~~~~
50
+
51
+ .. code-block:: python
52
+
53
+ create_spag_error(word: str) -> str
54
+
55
+ Introduces a 10% chance of a random spelling error in a given word, helpful for simulating typos.
56
+
57
+ **Parameters**:
58
+
59
+ - `word` (str): The original word to potentially alter.
60
+
61
+ introduce_spag_error
62
+ ~~~~~~~~~~~~~~~~~~~~
63
+
64
+ .. code-block:: python
65
+
66
+ introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame
67
+
68
+ Applies `create_spag_error` to each string entry in specified DataFrame columns, introducing random spelling errors with a 10% probability.
69
+
70
+ **Parameters**:
71
+
72
+ - `df` (pd.DataFrame): The DataFrame to alter.
73
+
74
+ - `columns` (list or str): Column names to apply errors to. Defaults to all string columns.
75
+
76
+ add_or_subtract_outliers
77
+ ~~~~~~~~~~~~~~~~~~~~~~~~
78
+
79
+ .. code-block:: python
80
+
81
+ add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame
82
+
83
+ Randomly adds or subtracts values in specified numeric columns, simulating outliers in 1% to 10% of rows.
84
+
85
+ **Parameters**:
86
+
87
+ - `df` (pd.DataFrame): The DataFrame to modify.
88
+
89
+ - `columns` (list or str): Column names to adjust. Defaults to all numeric columns if not specified.
90
+
91
+ add_standard_deviations
92
+ ~~~~~~~~~~~~~~~~~~~~~~~
93
+
94
+ .. code-block:: python
95
+
96
+ add_standard_deviations(df: pd.DataFrame, columns=None, min_std=1, max_std=5) -> pd.DataFrame
97
+
98
+ Adds between 1 to 5 standard deviations to random entries in numeric columns to simulate data anomalies.
99
+
100
+ **Parameters**:
101
+
102
+ - `df` (pd.DataFrame): The DataFrame to manipulate.
103
+
104
+ - `columns` (list or str): Column names to modify. Defaults to numeric columns if not specified.
105
+
106
+ - `min_std` (int): Minimum number of standard deviations to add. Defaults to 1.
107
+
108
+ - `max_std` (int): Maximum number of standard deviations to add. Defaults to 5.
109
+
110
+ duplicate_rows
111
+ ~~~~~~~~~~~~~~
112
+
113
+ .. code-block:: python
114
+
115
+ duplicate_rows(df: pd.DataFrame, sample_size=None) -> pd.DataFrame
116
+
117
+ Introduces duplicate rows into a DataFrame, useful for testing deduplication processes.
118
+
119
+ **Parameters**:
120
+
121
+ - `df` (pd.DataFrame): DataFrame to which duplicates will be added.
122
+
123
+ - `sample_size` (int): Number of rows to duplicate. A random percentage between 1% and 10% if not specified.
124
+
125
+ add_nulls
126
+ ~~~~~~~~~
127
+
128
+ .. code-block:: python
129
+
130
+ add_nulls(df: pd.DataFrame, columns=None, min_percent=1, max_percent=10) -> pd.DataFrame
131
+
132
+ Inserts null values into specified DataFrame columns, simulating missing data conditions.
133
+
134
+ **Parameters**:
135
+
136
+ - `df` (pd.DataFrame): The DataFrame to modify.
137
+
138
+ - `columns` (list or str): Specific columns to add nulls to. Defaults to all columns if not specified.
139
+
140
+ - `min_percent` (int): Minimum percentage of null values to insert. Defaults to 1%.
141
+
142
+ - `max_percent` (int): Maximum percentage of null values to insert. Defaults to 10%.
143
+
144
+ mess_it_up
145
+ ~~~~~~~~~~
146
+
147
+ .. code-block:: python
148
+
149
+ mess_it_up(df: pd.DataFrame, columns=None, min_std=1, max_std=5, sample_size=None, min_percent=1, max_percent=10,
150
+ introduce_spag=True, add_outliers=True, add_std=True, duplicate=True, add_null=True) -> pd.DataFrame
151
+
152
+ Integrates all methods to add errors comprehensively to the DataFrame.
153
+
154
+ **Parameters**:
155
+
156
+ - `df` (pd.DataFrame): The DataFrame to modify.
157
+
158
+ - `columns` (list or str): Specific columns to add nulls to. Defaults to all columns if not specified.
159
+
160
+ - `min_std` (int): Minimum number of standard deviations to add. Defaults to 1.
161
+
162
+ - `max_std` (int): Maximum number of standard deviations to add. Defaults to 5.
163
+
164
+ - `sample_size` (int): Number of rows to duplicate. Randomly selected if not specified.
165
+
166
+ - `min_percent` (int): Minimum percentage of null values to insert. Defaults to 1%.
167
+
168
+ - `max_percent` (int): Maximum percentage of null values to insert. Defaults to 10%.
169
+
170
+ - `introduce_spag` (bool): Adds spelling and grammar errors into string data. Defaults to True.
171
+
172
+ - `add_outliers` (bool): Adds outliers to numerical data. Defaults to True.
173
+
174
+ - `add_std` (bool): Adds standard deviations to the data. Defaults to True.
175
+
176
+ - `duplicate` (bool): Adds duplicate rows to the data. Defaults to True.
177
+
178
+ - `add_null` (bool): Adds null values to the dataset. Defaults to True.
179
+
180
+ Contributing
181
+ ------------
182
+
183
+ Feel free to contribute by submitting a pull request on GitHub. For large changes, please open an issue to discuss before implementing changes.
184
+
185
+ License
186
+ -------
187
+
188
+ This project is licensed under the MIT License. See the LICENSE file for details.
189
+
190
+ Contact Information
191
+ -------------------
192
+
193
+ For support or inquiries, please contact Ruy at ruyzambrano@gmail.com
194
+
195
+ Changelog
196
+ ---------
197
+
198
+ Version 0.3.2
199
+
200
+ Badges
201
+ ------
202
+
203
+ .. image:: https://img.shields.io/badge/build-passing-brightgreen
204
+ :target: https://github.com/yourusername/complexifier
205
+
206
+ .. image:: https://img.shields.io/badge/coverage-95%25-green
207
+ :target: https://codecov.io/gh/yourusername/complexifier
@@ -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.3.0"
6
+ version = "0.3.2"
7
7
  authors = [
8
8
  { name="Ruy Zambrano", email="ruyzambrano@gmail.com" },
9
9
  ]
@@ -49,7 +49,7 @@ def introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame:
49
49
 
50
50
  Args:
51
51
  df (pd.DataFrame): The DataFrame to alter.
52
- columns (list or str, optional): Column names to apply errors to. If not provided, defaults to all string columns.
52
+ columns (list or str): Column names to apply errors to. Defaults to all string columns.
53
53
 
54
54
  Returns:
55
55
  pd.DataFrame: The DataFrame with potential spelling errors introduced.
@@ -79,7 +79,7 @@ def add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame:
79
79
 
80
80
  Args:
81
81
  df (pd.DataFrame): The DataFrame to modify.
82
- columns (list or str, optional): Column names to adjust. Defaults to numeric columns if not specified.
82
+ columns (list or str): Column names to adjust. Defaults to all numeric columns if not specified.
83
83
 
84
84
  Returns:
85
85
  pd.DataFrame: The DataFrame with outliers added.
@@ -120,9 +120,9 @@ def add_standard_deviations(
120
120
 
121
121
  Args:
122
122
  df (pd.DataFrame): The DataFrame to manipulate.
123
- columns (list or str, optional): Column names to modify. Defaults to numeric columns if not specified.
124
- min_std (int): Minimum number of standard deviations to add.
125
- max_std (int): Maximum number of standard deviations to add.
123
+ columns (list or str): Column names to modify. Defaults to numeric columns if not specified.
124
+ min_std (int): Minimum number of standard deviations to add. Defaults to 1
125
+ max_std (int): Maximum number of standard deviations to add. Defaults to 5
126
126
 
127
127
  Returns:
128
128
  pd.DataFrame: The DataFrame with deviations added.
@@ -158,7 +158,7 @@ def duplicate_rows(df: pd.DataFrame, sample_size=None) -> pd.DataFrame:
158
158
 
159
159
  Args:
160
160
  df (pd.DataFrame): DataFrame to which duplicates will be added.
161
- sample_size (int, optional): Number of rows to duplicate. Randomly selected if not specified.
161
+ sample_size (int): number of rows to duplicate. A random percentage between 1% and 10% if not specified.
162
162
 
163
163
  Returns:
164
164
  pd.DataFrame: The DataFrame with duplicate rows added.
@@ -223,7 +223,7 @@ def mess_it_up(
223
223
  add_outliers=True,
224
224
  add_std=True,
225
225
  duplicate=True,
226
- add_null=True,
226
+ add_null=True
227
227
  ) -> pd.DataFrame:
228
228
  """
229
229
  Applies several functions to add outliers, spelling errors and null values
@@ -236,6 +236,11 @@ def mess_it_up(
236
236
  sample_size (int, optional): Number of rows to duplicate. Randomly selected if not specified.
237
237
  min_percent (int): Minimum percentage of null values to insert. Defaults to 1%
238
238
  max_percent (int): Maximum percentage of null values to insert. Defaults to 10%
239
+ introduce_spag (bool): Adds spelling and grammar errors into string data. Defaults to True
240
+ add_outliers (bool): Adds outliers to numerical data. Defaults to True
241
+ add_std (bool): Adds standard deviations to the data. Defaults to True
242
+ duplicate (bool): Adds duplicate rows to the data. Defaults to True
243
+ add_null (bool): Adds null values to the dataset. Defaults to True
239
244
 
240
245
  """
241
246
  if not isinstance(df, pd.DataFrame):
@@ -254,15 +259,19 @@ def mess_it_up(
254
259
  string_cols = df[columns].select_dtypes(include="string").columns.to_list()
255
260
  numeric_cols = df[columns].select_dtypes(include="number").columns.to_list()
256
261
  if string_cols:
257
- df = introduce_spag_error(df, columns=string_cols)
262
+ if introduce_spag:
263
+ df = introduce_spag_error(df, string_cols)
258
264
  if numeric_cols:
259
- df = add_or_subtract_outliers(df, columns=numeric_cols)
260
- df = add_standard_deviations(
261
- df, columns=numeric_cols, min_std=min_std, max_std=max_std
262
- )
263
-
264
- df = duplicate_rows(df, sample_size)
265
- df = add_nulls(df, columns, min_percent=min_percent, max_percent=max_percent)
265
+ if add_outliers:
266
+ df = add_or_subtract_outliers(df, numeric_cols)
267
+ if add_std:
268
+ df = add_standard_deviations(
269
+ df, numeric_cols, min_std, max_std
270
+ )
271
+ if duplicate:
272
+ df = duplicate_rows(df, sample_size)
273
+ if add_null:
274
+ df = add_nulls(df, columns, min_percent, max_percent)
266
275
  return df
267
276
 
268
277
 
@@ -1,71 +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
- ### `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.
File without changes