complexifier 0.3.2__tar.gz → 1.0.0__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.
- {complexifier-0.3.2 → complexifier-1.0.0}/.github/workflows/main.yml +1 -2
- {complexifier-0.3.2 → complexifier-1.0.0}/.github/workflows/sphinx.yml +16 -0
- complexifier-1.0.0/.readthedocs.yaml +32 -0
- {complexifier-0.3.2 → complexifier-1.0.0}/PKG-INFO +7 -3
- {complexifier-0.3.2 → complexifier-1.0.0}/README.md +4 -1
- complexifier-1.0.0/README.rst +108 -0
- complexifier-1.0.0/docs/.nojekyll +0 -0
- {complexifier-0.3.2 → complexifier-1.0.0}/docs/source/conf.py +13 -8
- complexifier-1.0.0/docs/source/index.rst +108 -0
- {complexifier-0.3.2 → complexifier-1.0.0}/pyproject.toml +1 -1
- complexifier-1.0.0/src/complexifier/__init__.py +9 -0
- {complexifier-0.3.2 → complexifier-1.0.0}/src/complexifier/main.py +108 -107
- complexifier-0.3.2/README.rst +0 -182
- complexifier-0.3.2/docs/source/index.rst +0 -207
- complexifier-0.3.2/src/complexifier/__init__.py +0 -1
- {complexifier-0.3.2 → complexifier-1.0.0}/.gitignore +0 -0
- {complexifier-0.3.2 → complexifier-1.0.0}/LICENSE +0 -0
- {complexifier-0.3.2 → complexifier-1.0.0}/docs/Makefile +0 -0
- {complexifier-0.3.2 → complexifier-1.0.0}/docs/make.bat +0 -0
- {complexifier-0.3.2 → complexifier-1.0.0/docs/source}/assets/complexifier.jpeg +0 -0
- {complexifier-0.3.2 → complexifier-1.0.0}/src/complexifier/test_main.py +0 -0
|
@@ -11,13 +11,29 @@ jobs:
|
|
|
11
11
|
- uses: actions/checkout@v4
|
|
12
12
|
with:
|
|
13
13
|
persist-credentials: false
|
|
14
|
+
|
|
15
|
+
# - name: Set up Python
|
|
16
|
+
# uses: actions/setup-python@v4
|
|
17
|
+
# with:
|
|
18
|
+
# python-version: '3.x'
|
|
19
|
+
|
|
20
|
+
# - name: Install dependencies
|
|
21
|
+
# run: |
|
|
22
|
+
# python -m pip install --upgrade pip
|
|
23
|
+
# pip install -r requirements.txt
|
|
24
|
+
|
|
25
|
+
# - name: Check installed packages
|
|
26
|
+
# run: python -m pip list
|
|
27
|
+
|
|
14
28
|
- name: Build HTML
|
|
15
29
|
uses: ammaraskar/sphinx-action@master
|
|
30
|
+
|
|
16
31
|
- name: Upload artifacts
|
|
17
32
|
uses: actions/upload-artifact@v4
|
|
18
33
|
with:
|
|
19
34
|
name: html-docs
|
|
20
35
|
path: docs/build/html/
|
|
36
|
+
|
|
21
37
|
- name: Deploy
|
|
22
38
|
uses: peaceiris/actions-gh-pages@v3
|
|
23
39
|
if: github.ref == 'refs/heads/main'
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# .readthedocs.yaml
|
|
2
|
+
# Read the Docs configuration file
|
|
3
|
+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
|
4
|
+
|
|
5
|
+
# Required
|
|
6
|
+
version: 2
|
|
7
|
+
|
|
8
|
+
# Set the OS, Python version and other tools you might need
|
|
9
|
+
build:
|
|
10
|
+
os: ubuntu-24.04
|
|
11
|
+
tools:
|
|
12
|
+
python: "3.13"
|
|
13
|
+
# You can also specify other tool versions:
|
|
14
|
+
# nodejs: "23"
|
|
15
|
+
# rust: "1.82"
|
|
16
|
+
# golang: "1.23"
|
|
17
|
+
|
|
18
|
+
# Build documentation in the "docs/" directory with Sphinx
|
|
19
|
+
sphinx:
|
|
20
|
+
configuration: docs/source/conf.py
|
|
21
|
+
|
|
22
|
+
# Optionally build your docs in additional formats such as PDF and ePub
|
|
23
|
+
# formats:
|
|
24
|
+
# - pdf
|
|
25
|
+
# - epub
|
|
26
|
+
|
|
27
|
+
# Optional but recommended, declare the Python requirements required
|
|
28
|
+
# to build your documentation
|
|
29
|
+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
|
|
30
|
+
python:
|
|
31
|
+
install:
|
|
32
|
+
- requirements: docs/requirements.txt
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: complexifier
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
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
|
|
7
7
|
Author-email: Ruy Zambrano <ruyzambrano@gmail.com>
|
|
8
|
+
License-File: LICENSE
|
|
8
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
9
10
|
Classifier: Operating System :: OS Independent
|
|
10
11
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -40,10 +41,13 @@ Complexifier solves this problem by allowing you take the former and turn it int
|
|
|
40
41
|
pip install complexifier
|
|
41
42
|
```
|
|
42
43
|
|
|
43
|
-
##
|
|
44
|
+
## Documentation
|
|
44
45
|
|
|
45
46
|
[Go to the documentation](https://ruyzambrano.github.io/complexifier/)
|
|
46
47
|
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
|
|
47
51
|
Once installed you can use `complexifier` to add mistakes and outliers to your data
|
|
48
52
|
|
|
49
53
|
This library has several methods available:
|
|
@@ -27,10 +27,13 @@ Complexifier solves this problem by allowing you take the former and turn it int
|
|
|
27
27
|
pip install complexifier
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
##
|
|
30
|
+
## Documentation
|
|
31
31
|
|
|
32
32
|
[Go to the documentation](https://ruyzambrano.github.io/complexifier/)
|
|
33
33
|
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
|
|
34
37
|
Once installed you can use `complexifier` to add mistakes and outliers to your data
|
|
35
38
|
|
|
36
39
|
This library has several methods available:
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
.. autofunction:: complexifier.create_spag_error
|
|
52
|
+
|
|
53
|
+
introduce_spag_error
|
|
54
|
+
~~~~~~~~~~~~~~~~~~~~
|
|
55
|
+
|
|
56
|
+
.. autofunction:: complexifier.introduce_spag_error
|
|
57
|
+
|
|
58
|
+
add_or_subtract_outliers
|
|
59
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
60
|
+
|
|
61
|
+
.. autofunction:: complexifier.add_or_subtract_outliers
|
|
62
|
+
|
|
63
|
+
add_standard_deviations
|
|
64
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
65
|
+
|
|
66
|
+
.. autofunction:: complexifier.add_standard_deviations
|
|
67
|
+
|
|
68
|
+
duplicate_rows
|
|
69
|
+
~~~~~~~~~~~~~~
|
|
70
|
+
|
|
71
|
+
.. autofunction:: complexifier.duplicate_rows
|
|
72
|
+
|
|
73
|
+
add_nulls
|
|
74
|
+
~~~~~~~~~
|
|
75
|
+
|
|
76
|
+
.. autofunction:: complexifier.add_nulls
|
|
77
|
+
|
|
78
|
+
mess_it_up
|
|
79
|
+
~~~~~~~~~~
|
|
80
|
+
|
|
81
|
+
.. autofunction:: complexifier.mess_it_up
|
|
82
|
+
|
|
83
|
+
Contributing
|
|
84
|
+
------------
|
|
85
|
+
|
|
86
|
+
Feel free to contribute by submitting a pull request on GitHub. For large changes, please open an issue to discuss before implementing changes.
|
|
87
|
+
|
|
88
|
+
License
|
|
89
|
+
-------
|
|
90
|
+
|
|
91
|
+
This project is licensed under the MIT License. See the LICENSE file for details.
|
|
92
|
+
|
|
93
|
+
Contact Information
|
|
94
|
+
-------------------
|
|
95
|
+
|
|
96
|
+
For support or inquiries, please contact Ruy at ruyzambrano@gmail.com
|
|
97
|
+
|
|
98
|
+
Changelog
|
|
99
|
+
---------
|
|
100
|
+
|
|
101
|
+
Version 0.3.3
|
|
102
|
+
|
|
103
|
+
Badges
|
|
104
|
+
------
|
|
105
|
+
|
|
106
|
+
.. image:: https://github.com/ruyzambrano/complexifier/workflows/Test/badge.svg
|
|
107
|
+
:target: https://github.com/ruyzambrano/complexifier/actions
|
|
108
|
+
|
|
File without changes
|
|
@@ -6,23 +6,28 @@
|
|
|
6
6
|
# -- Project information -----------------------------------------------------
|
|
7
7
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
|
8
8
|
|
|
9
|
-
project =
|
|
10
|
-
copyright =
|
|
11
|
-
author =
|
|
12
|
-
release =
|
|
9
|
+
project = "Complexifier"
|
|
10
|
+
copyright = "2024, Ruy Zambrano"
|
|
11
|
+
author = "Ruy Zambrano"
|
|
12
|
+
release = "0.3.1"
|
|
13
13
|
|
|
14
14
|
# -- General configuration ---------------------------------------------------
|
|
15
15
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
|
16
16
|
|
|
17
|
-
extensions = []
|
|
17
|
+
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon", "sphinx.ext.githubpages"]
|
|
18
18
|
|
|
19
|
-
templates_path = [
|
|
19
|
+
templates_path = ["_templates"]
|
|
20
|
+
html_static_path = ["_static"]
|
|
20
21
|
exclude_patterns = []
|
|
21
22
|
|
|
23
|
+
import os
|
|
24
|
+
import sys
|
|
22
25
|
|
|
26
|
+
sys.path.insert(0, os.path.abspath("../../src"))
|
|
23
27
|
|
|
24
28
|
# -- Options for HTML output -------------------------------------------------
|
|
25
29
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
|
|
32
|
+
html_theme = "sphinx_rtd_theme"
|
|
33
|
+
html_logo = "assets/complexifier.jpeg"
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
.. autofunction:: complexifier.create_spag_error
|
|
52
|
+
|
|
53
|
+
introduce_spag_error
|
|
54
|
+
~~~~~~~~~~~~~~~~~~~~
|
|
55
|
+
|
|
56
|
+
.. autofunction:: complexifier.introduce_spag_error
|
|
57
|
+
|
|
58
|
+
add_or_subtract_outliers
|
|
59
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
60
|
+
|
|
61
|
+
.. autofunction:: complexifier.add_or_subtract_outliers
|
|
62
|
+
|
|
63
|
+
add_standard_deviations
|
|
64
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
65
|
+
|
|
66
|
+
.. autofunction:: complexifier.add_standard_deviations
|
|
67
|
+
|
|
68
|
+
duplicate_rows
|
|
69
|
+
~~~~~~~~~~~~~~
|
|
70
|
+
|
|
71
|
+
.. autofunction:: complexifier.duplicate_rows
|
|
72
|
+
|
|
73
|
+
add_nulls
|
|
74
|
+
~~~~~~~~~
|
|
75
|
+
|
|
76
|
+
.. autofunction:: complexifier.add_nulls
|
|
77
|
+
|
|
78
|
+
mess_it_up
|
|
79
|
+
~~~~~~~~~~
|
|
80
|
+
|
|
81
|
+
.. autofunction:: complexifier.mess_it_up
|
|
82
|
+
|
|
83
|
+
Contributing
|
|
84
|
+
------------
|
|
85
|
+
|
|
86
|
+
Feel free to contribute by submitting a pull request on GitHub. For large changes, please open an issue to discuss before implementing changes.
|
|
87
|
+
|
|
88
|
+
License
|
|
89
|
+
-------
|
|
90
|
+
|
|
91
|
+
This project is licensed under the MIT License. See the LICENSE file for details.
|
|
92
|
+
|
|
93
|
+
Contact Information
|
|
94
|
+
-------------------
|
|
95
|
+
|
|
96
|
+
For support or inquiries, please contact Ruy at ruyzambrano@gmail.com
|
|
97
|
+
|
|
98
|
+
Changelog
|
|
99
|
+
---------
|
|
100
|
+
|
|
101
|
+
Version 0.3.3
|
|
102
|
+
|
|
103
|
+
Badges
|
|
104
|
+
------
|
|
105
|
+
|
|
106
|
+
.. image:: https://github.com/ruyzambrano/complexifier/workflows/Test/badge.svg
|
|
107
|
+
:target: https://github.com/ruyzambrano/complexifier/actions
|
|
108
|
+
|
|
@@ -1,58 +1,57 @@
|
|
|
1
1
|
import random
|
|
2
|
-
|
|
3
2
|
from typo import StrErrer
|
|
4
3
|
import pandas as pd
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
def create_spag_error(word: str) -> str:
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
Args:
|
|
11
|
-
word (str): The original word to potentially alter.
|
|
7
|
+
"""
|
|
8
|
+
Gives a 10% chance to introduce a spelling error to a word.
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
:param word: The original word to potentially alter.
|
|
11
|
+
:type word: str
|
|
12
|
+
:return: The original word or a word with a random spelling error.
|
|
13
|
+
:rtype: str
|
|
15
14
|
"""
|
|
16
15
|
if len(word) < 3:
|
|
17
16
|
return word
|
|
18
17
|
error_object = StrErrer(word)
|
|
19
18
|
weight = random.randint(1, 100)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return word
|
|
19
|
+
if weight == 1:
|
|
20
|
+
return error_object.missing_char().result
|
|
21
|
+
elif weight == 2:
|
|
22
|
+
return error_object.char_swap().result
|
|
23
|
+
elif weight == 3:
|
|
24
|
+
return error_object.extra_char().result
|
|
25
|
+
elif weight == 4:
|
|
26
|
+
return error_object.nearby_char().result
|
|
27
|
+
elif weight == 5:
|
|
28
|
+
return error_object.similar_char().result
|
|
29
|
+
elif weight == 6:
|
|
30
|
+
return error_object.random_space().result
|
|
31
|
+
elif weight == 7:
|
|
32
|
+
return error_object.repeated_char().result
|
|
33
|
+
elif weight == 8:
|
|
34
|
+
return word.lower()
|
|
35
|
+
elif weight == 9:
|
|
36
|
+
return word.upper()
|
|
37
|
+
elif weight == 10:
|
|
38
|
+
return "".join(
|
|
39
|
+
[char.upper() if random.randint(0, 100) < 10 else char for char in word]
|
|
40
|
+
)
|
|
41
|
+
else:
|
|
42
|
+
return word
|
|
45
43
|
|
|
46
44
|
|
|
47
45
|
def introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame:
|
|
48
|
-
"""
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
"""
|
|
47
|
+
Applies random spelling errors to specified columns in a DataFrame.
|
|
48
|
+
|
|
49
|
+
:param df: The DataFrame to alter.
|
|
50
|
+
:type df: pd.DataFrame
|
|
51
|
+
:param columns: Column names to apply errors to. Defaults to all string columns.
|
|
52
|
+
:type columns: list or str, optional
|
|
53
|
+
:return: The DataFrame with potential spelling errors introduced.
|
|
54
|
+
:rtype: pd.DataFrame
|
|
56
55
|
"""
|
|
57
56
|
if not isinstance(df, pd.DataFrame):
|
|
58
57
|
raise TypeError("Must be a pandas")
|
|
@@ -75,14 +74,15 @@ def introduce_spag_error(df: pd.DataFrame, columns=None) -> pd.DataFrame:
|
|
|
75
74
|
|
|
76
75
|
|
|
77
76
|
def add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame:
|
|
78
|
-
"""
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
"""
|
|
78
|
+
Adds or subtracts a random integer in columns of between 1% and 10% of the rows.
|
|
79
|
+
|
|
80
|
+
:param df: The DataFrame to modify.
|
|
81
|
+
:type df: pd.DataFrame
|
|
82
|
+
:param columns: Column names to adjust. Defaults to all numeric columns if not specified.
|
|
83
|
+
:type columns: list or str, optional
|
|
84
|
+
:return: The DataFrame with outliers added.
|
|
85
|
+
:rtype: pd.DataFrame
|
|
86
86
|
"""
|
|
87
87
|
if not isinstance(df, pd.DataFrame):
|
|
88
88
|
raise TypeError("Must be a pandas")
|
|
@@ -95,11 +95,6 @@ def add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame:
|
|
|
95
95
|
elif not isinstance(columns, list):
|
|
96
96
|
raise TypeError(f"Columns is type {type(columns)} but expected str or list")
|
|
97
97
|
|
|
98
|
-
elif isinstance(columns, str):
|
|
99
|
-
columns = [columns]
|
|
100
|
-
elif not isinstance(columns, list):
|
|
101
|
-
raise TypeError(f"Columns is type {type(columns)} but expected str or list")
|
|
102
|
-
|
|
103
98
|
for col in columns:
|
|
104
99
|
if col not in df.columns:
|
|
105
100
|
raise ValueError(f"{col} is not a column.")
|
|
@@ -116,16 +111,19 @@ def add_or_subtract_outliers(df: pd.DataFrame, columns=None) -> pd.DataFrame:
|
|
|
116
111
|
def add_standard_deviations(
|
|
117
112
|
df: pd.DataFrame, columns=None, min_std=1, max_std=5
|
|
118
113
|
) -> pd.DataFrame:
|
|
119
|
-
"""
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
114
|
+
"""
|
|
115
|
+
Adds random deviations to entries in specified numeric columns to simulate data anomalies.
|
|
116
|
+
|
|
117
|
+
:param df: The DataFrame to manipulate.
|
|
118
|
+
:type df: pd.DataFrame
|
|
119
|
+
:param columns: Column names to modify. Defaults to numeric columns if not specified.
|
|
120
|
+
:type columns: list or str, optional
|
|
121
|
+
:param min_std: Minimum number of standard deviations to add. Defaults to 1
|
|
122
|
+
:type min_std: int, optional
|
|
123
|
+
:param max_std: Maximum number of standard deviations to add. Defaults to 5
|
|
124
|
+
:type max_std: int, optional
|
|
125
|
+
:return: The DataFrame with deviations added.
|
|
126
|
+
:rtype: pd.DataFrame
|
|
129
127
|
"""
|
|
130
128
|
if not isinstance(df, pd.DataFrame):
|
|
131
129
|
raise TypeError("Must be a pandas")
|
|
@@ -154,14 +152,15 @@ def add_standard_deviations(
|
|
|
154
152
|
|
|
155
153
|
|
|
156
154
|
def duplicate_rows(df: pd.DataFrame, sample_size=None) -> pd.DataFrame:
|
|
157
|
-
"""
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
155
|
+
"""
|
|
156
|
+
Adds duplicate rows to a DataFrame.
|
|
157
|
+
|
|
158
|
+
:param df: DataFrame to which duplicates will be added.
|
|
159
|
+
:type df: pd.DataFrame
|
|
160
|
+
:param sample_size: Number of rows to duplicate. A random percentage between 1% and 10% if not specified.
|
|
161
|
+
:type sample_size: int, optional
|
|
162
|
+
:return: The DataFrame with duplicate rows added.
|
|
163
|
+
:rtype: pd.DataFrame
|
|
165
164
|
"""
|
|
166
165
|
if not isinstance(df, pd.DataFrame):
|
|
167
166
|
raise TypeError("Must be a pandas")
|
|
@@ -179,14 +178,16 @@ def add_nulls(
|
|
|
179
178
|
"""
|
|
180
179
|
Inserts null values into specified DataFrame columns.
|
|
181
180
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
181
|
+
:param df: The DataFrame to modify.
|
|
182
|
+
:type df: pd.DataFrame
|
|
183
|
+
:param columns: Specific columns to add nulls to. Defaults to all columns if not specified.
|
|
184
|
+
:type columns: list or str, optional
|
|
185
|
+
:param min_percent: Minimum percentage of null values to insert. Defaults to 1%
|
|
186
|
+
:type min_percent: int, optional
|
|
187
|
+
:param max_percent: Maximum percentage of null values to insert. Defaults to 10%
|
|
188
|
+
:type max_percent: int, optional
|
|
189
|
+
:return: The DataFrame with null values inserted.
|
|
190
|
+
:rtype: pd.DataFrame
|
|
190
191
|
"""
|
|
191
192
|
if not isinstance(df, pd.DataFrame):
|
|
192
193
|
raise TypeError("Must be a pandas")
|
|
@@ -223,25 +224,37 @@ def mess_it_up(
|
|
|
223
224
|
add_outliers=True,
|
|
224
225
|
add_std=True,
|
|
225
226
|
duplicate=True,
|
|
226
|
-
add_null=True
|
|
227
|
+
add_null=True,
|
|
227
228
|
) -> pd.DataFrame:
|
|
228
229
|
"""
|
|
229
230
|
Applies several functions to add outliers, spelling errors and null values
|
|
230
231
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
232
|
+
:param df: The DataFrame to modify.
|
|
233
|
+
:type df: pd.DataFrame
|
|
234
|
+
:param columns: Specific columns to modify. Defaults to all columns if not specified.
|
|
235
|
+
:type columns: list or str, optional
|
|
236
|
+
:param min_std: Minimum number of standard deviations to add. Defaults to 1
|
|
237
|
+
:type min_std: int, optional
|
|
238
|
+
:param max_std: Maximum number of standard deviations to add. Defaults to 5
|
|
239
|
+
:type max_std: int, optional
|
|
240
|
+
:param sample_size: Number of rows to duplicate. Randomly selected if not specified.
|
|
241
|
+
:type sample_size: int, optional
|
|
242
|
+
:param min_percent: Minimum percentage of null values to insert. Defaults to 1%
|
|
243
|
+
:type min_percent: int, optional
|
|
244
|
+
:param max_percent: Maximum percentage of null values to insert. Defaults to 10%
|
|
245
|
+
:type max_percent: int, optional
|
|
246
|
+
:param introduce_spag: Adds spelling and grammar errors into string data. Defaults to True
|
|
247
|
+
:type introduce_spag: bool, optional
|
|
248
|
+
:param add_outliers: Adds outliers to numerical data. Defaults to True
|
|
249
|
+
:type add_outliers: bool, optional
|
|
250
|
+
:param add_std: Adds standard deviations to the data. Defaults to True
|
|
251
|
+
:type add_std: bool, optional
|
|
252
|
+
:param duplicate: Adds duplicate rows to the data. Defaults to True
|
|
253
|
+
:type duplicate: bool, optional
|
|
254
|
+
:param add_null: Adds null values to the dataset. Defaults to True
|
|
255
|
+
:type add_null: bool, optional
|
|
256
|
+
:return: The modified DataFrame.
|
|
257
|
+
:rtype: pd.DataFrame
|
|
245
258
|
"""
|
|
246
259
|
if not isinstance(df, pd.DataFrame):
|
|
247
260
|
raise TypeError("Must be a pandas")
|
|
@@ -265,21 +278,9 @@ def mess_it_up(
|
|
|
265
278
|
if add_outliers:
|
|
266
279
|
df = add_or_subtract_outliers(df, numeric_cols)
|
|
267
280
|
if add_std:
|
|
268
|
-
df = add_standard_deviations(
|
|
269
|
-
df, numeric_cols, min_std, max_std
|
|
270
|
-
)
|
|
281
|
+
df = add_standard_deviations(df, numeric_cols, min_std, max_std)
|
|
271
282
|
if duplicate:
|
|
272
283
|
df = duplicate_rows(df, sample_size)
|
|
273
284
|
if add_null:
|
|
274
285
|
df = add_nulls(df, columns, min_percent, max_percent)
|
|
275
286
|
return df
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
data = pd.DataFrame(
|
|
279
|
-
{
|
|
280
|
-
"Name": ["Alice", "Bob", "Charlie", "David", "Eva"],
|
|
281
|
-
"Age": [28, 34, 29, 42, 25],
|
|
282
|
-
"City": ["New York", "Los Angeles", "Chicago", "Houston", "Phoenix"],
|
|
283
|
-
"Salary": [70000, 80000, 72000, 95000, 67000],
|
|
284
|
-
}
|
|
285
|
-
)
|
complexifier-0.3.2/README.rst
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
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
|
|
@@ -1,207 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .main import *
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|