menddata 0.1.0__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.
- MendData/__init__.py +133 -0
- MendData/audit.py +147 -0
- MendData/detectors.py +386 -0
- MendData/fixers.py +511 -0
- MendData/issue.py +236 -0
- MendData/scoring.py +229 -0
- MendData/session.py +502 -0
- MendData/utils.py +82 -0
- menddata-0.1.0.dist-info/METADATA +295 -0
- menddata-0.1.0.dist-info/RECORD +13 -0
- menddata-0.1.0.dist-info/WHEEL +5 -0
- menddata-0.1.0.dist-info/licenses/LICENSE +21 -0
- menddata-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: menddata
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A beginner-friendly data cleaning library for pandas: scan, fix, score and explain every change in plain English.
|
|
5
|
+
Home-page: https://github.com/yninika/MendData
|
|
6
|
+
Author: Group 4 (DS2C): Ferolino, Coniendo, Jusol, Obrador
|
|
7
|
+
Author-email: ferolino.analynica23@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: pandas
|
|
18
|
+
Requires-Dist: numpy
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pytest; extra == "dev"
|
|
21
|
+
Dynamic: author
|
|
22
|
+
Dynamic: author-email
|
|
23
|
+
Dynamic: classifier
|
|
24
|
+
Dynamic: description
|
|
25
|
+
Dynamic: description-content-type
|
|
26
|
+
Dynamic: home-page
|
|
27
|
+
Dynamic: license
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
Dynamic: provides-extra
|
|
30
|
+
Dynamic: requires-dist
|
|
31
|
+
Dynamic: requires-python
|
|
32
|
+
Dynamic: summary
|
|
33
|
+
|
|
34
|
+
# MendData
|
|
35
|
+
|
|
36
|
+
A beginner-friendly **data cleaning library for pandas**. MendData follows one
|
|
37
|
+
simple order of work:
|
|
38
|
+
|
|
39
|
+
1. **Scan** the data for problems (missing values, duplicate rows, outliers).
|
|
40
|
+
2. **Fix** each problem with a strategy you choose.
|
|
41
|
+
3. **Score** the data quality before and after cleaning.
|
|
42
|
+
4. **Explain** every change in plain English.
|
|
43
|
+
|
|
44
|
+
It is built for students and beginner analysts working with tabular data, and
|
|
45
|
+
it is written with Object-Oriented Programming in mind: detectors find issues,
|
|
46
|
+
fixers resolve them, and `Issue` is the shared contract between the two.
|
|
47
|
+
|
|
48
|
+
> Course project of Group 4, Section DS2C.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install menddata
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Until the package is published, install it from the repository:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
git clone https://github.com/yninika/MendData.git
|
|
60
|
+
cd MendData
|
|
61
|
+
pip install -e .
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Requires Python 3.9 or newer. The only dependencies are `pandas` and `numpy`.
|
|
65
|
+
|
|
66
|
+
## Quick start
|
|
67
|
+
|
|
68
|
+
Methods return values and never print, so wrap them in `print()`.
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
import pandas as pd
|
|
72
|
+
from MendData import CleaningSession, ImputeFixer
|
|
73
|
+
|
|
74
|
+
df = pd.read_csv("messy_data.csv")
|
|
75
|
+
|
|
76
|
+
session = CleaningSession(df) # wraps a copy of your DataFrame
|
|
77
|
+
session.scan() # find issues, ranked by severity
|
|
78
|
+
session.fix_all() # default fixers: median fill, drop duplicates, clip outliers
|
|
79
|
+
print(session.score()) # {'before': ..., 'after': ..., 'change': ...}
|
|
80
|
+
print(session.report()) # plain-English summary of changes
|
|
81
|
+
session.undo() # revert the last cleaning step
|
|
82
|
+
session.reset() # go back to the original data
|
|
83
|
+
|
|
84
|
+
clean_df = session.data # a copy of the current data
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Choose a strategy for each kind of issue:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
session.fix_all(fixers={"missing": ImputeFixer("mean")})
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Your original DataFrame is never modified.
|
|
94
|
+
|
|
95
|
+
## Features
|
|
96
|
+
|
|
97
|
+
| # | Feature | What it does | Main classes |
|
|
98
|
+
|---|---------|--------------|--------------|
|
|
99
|
+
| 1 | Issue scanning | Detects missing values, duplicate rows and outliers (IQR or z-score). Each problem becomes an `Issue` with a severity from 0 to 1, ranked highest first. | `Issue`, `BaseDetector` and subclasses |
|
|
100
|
+
| 2 | Strategy-based fixing | Impute (mean, median, mode), drop, or clip, chosen per kind of issue, with sensible defaults. | `BaseFixer` and subclasses |
|
|
101
|
+
| 3 | Data quality score | Rates the data from 0 to 100 using completeness, uniqueness and validity (default weights 40/30/30), before and after cleaning. | `QualityScorer` |
|
|
102
|
+
| 4 | Plain-English audit log | Append-only record of what each step did, why, and how many rows or cells it affected. | `AuditLog` |
|
|
103
|
+
| 5 | Undo and step history | `undo()` reverts the last step, `reset()` returns to the original data. Keeps the last 20 steps by default. | `CleaningSession` |
|
|
104
|
+
|
|
105
|
+
## Using the pieces on their own
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from MendData import OutlierDetector, ClipFixer, QualityScorer
|
|
109
|
+
|
|
110
|
+
detector = OutlierDetector(method="zscore", threshold=3.0, min_severity=0.01)
|
|
111
|
+
issues = sorted(detector.detect(df), reverse=True)
|
|
112
|
+
|
|
113
|
+
for issue in issues:
|
|
114
|
+
print(issue) # plain-English description
|
|
115
|
+
print(ClipFixer().explain(issue))
|
|
116
|
+
df = ClipFixer().fix(df, issue) # returns a new DataFrame
|
|
117
|
+
|
|
118
|
+
print(QualityScorer().breakdown(df)) # completeness, uniqueness, validity
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Class design
|
|
122
|
+
|
|
123
|
+
| Class | Role |
|
|
124
|
+
|-------|------|
|
|
125
|
+
| `Issue` | Immutable description of one problem (column, kind, count, severity, details) |
|
|
126
|
+
| `BaseDetector` (abstract) | `MissingValueDetector`, `DuplicateDetector`, `OutlierDetector` |
|
|
127
|
+
| `BaseFixer` (abstract) | `ImputeFixer`, `DropFixer`, `ClipFixer` |
|
|
128
|
+
| `QualityScorer` | Weighted 0-100 quality score |
|
|
129
|
+
| `AuditLog` | Append-only, exportable history |
|
|
130
|
+
| `CleaningSession` | Main entry point; owns the detectors, fixers, scorer and log |
|
|
131
|
+
|
|
132
|
+
```mermaid
|
|
133
|
+
classDiagram
|
|
134
|
+
direction TB
|
|
135
|
+
|
|
136
|
+
class Issue {
|
|
137
|
+
+MISSING$
|
|
138
|
+
+DUPLICATE$
|
|
139
|
+
+OUTLIER$
|
|
140
|
+
+KINDS$
|
|
141
|
+
-_column
|
|
142
|
+
-_kind
|
|
143
|
+
-_count
|
|
144
|
+
-_severity
|
|
145
|
+
-_details
|
|
146
|
+
+column
|
|
147
|
+
+kind
|
|
148
|
+
+count
|
|
149
|
+
+severity
|
|
150
|
+
+details
|
|
151
|
+
+describe() str
|
|
152
|
+
+__repr__() str
|
|
153
|
+
+__str__() str
|
|
154
|
+
+__eq__(other) bool
|
|
155
|
+
+__hash__() int
|
|
156
|
+
+__lt__(other) bool
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
class BaseDetector {
|
|
160
|
+
<<abstract>>
|
|
161
|
+
-_min_severity
|
|
162
|
+
+min_severity
|
|
163
|
+
+detect(data)* list
|
|
164
|
+
}
|
|
165
|
+
class MissingValueDetector {
|
|
166
|
+
+detect(data) list
|
|
167
|
+
}
|
|
168
|
+
class DuplicateDetector {
|
|
169
|
+
-_subset
|
|
170
|
+
+subset
|
|
171
|
+
+detect(data) list
|
|
172
|
+
}
|
|
173
|
+
class OutlierDetector {
|
|
174
|
+
-_method
|
|
175
|
+
-_threshold
|
|
176
|
+
+method
|
|
177
|
+
+threshold
|
|
178
|
+
+detect(data) list
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
class BaseFixer {
|
|
182
|
+
<<abstract>>
|
|
183
|
+
+HANDLES$
|
|
184
|
+
-_strategy
|
|
185
|
+
+strategy
|
|
186
|
+
+can_fix(issue) bool
|
|
187
|
+
+fix(data, issue)* DataFrame
|
|
188
|
+
+explain(issue)* str
|
|
189
|
+
}
|
|
190
|
+
class ImputeFixer {
|
|
191
|
+
+fix(data, issue) DataFrame
|
|
192
|
+
+explain(issue) str
|
|
193
|
+
}
|
|
194
|
+
class DropFixer {
|
|
195
|
+
+fix(data, issue) DataFrame
|
|
196
|
+
+explain(issue) str
|
|
197
|
+
}
|
|
198
|
+
class ClipFixer {
|
|
199
|
+
+fix(data, issue) DataFrame
|
|
200
|
+
+explain(issue) str
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
class QualityScorer {
|
|
204
|
+
-_weights
|
|
205
|
+
+weights
|
|
206
|
+
+breakdown(data) dict
|
|
207
|
+
+score(data) float
|
|
208
|
+
+compare(before, after) dict
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
class AuditLog {
|
|
212
|
+
-_entries
|
|
213
|
+
+entries
|
|
214
|
+
+record(step, reason, affected) None
|
|
215
|
+
+export(path) str
|
|
216
|
+
+__len__() int
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
class CleaningSession {
|
|
220
|
+
-_data
|
|
221
|
+
-_original
|
|
222
|
+
-_history
|
|
223
|
+
-_issues
|
|
224
|
+
-_detectors
|
|
225
|
+
-_fixers
|
|
226
|
+
-_scorer
|
|
227
|
+
-_log
|
|
228
|
+
-_max_history
|
|
229
|
+
+data
|
|
230
|
+
+issues
|
|
231
|
+
+scan() list
|
|
232
|
+
+fix(issue, fixer) DataFrame
|
|
233
|
+
+fix_all(fixers) DataFrame
|
|
234
|
+
+score() dict
|
|
235
|
+
+report() str
|
|
236
|
+
+undo() DataFrame
|
|
237
|
+
+reset() DataFrame
|
|
238
|
+
+__repr__() str
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
BaseDetector <|-- MissingValueDetector
|
|
242
|
+
BaseDetector <|-- DuplicateDetector
|
|
243
|
+
BaseDetector <|-- OutlierDetector
|
|
244
|
+
BaseFixer <|-- ImputeFixer
|
|
245
|
+
BaseFixer <|-- DropFixer
|
|
246
|
+
BaseFixer <|-- ClipFixer
|
|
247
|
+
|
|
248
|
+
CleaningSession "1" *-- "1..*" BaseDetector : scans with
|
|
249
|
+
CleaningSession "1" *-- "1..*" BaseFixer : fixes with
|
|
250
|
+
CleaningSession "1" *-- "1" QualityScorer : scores with
|
|
251
|
+
CleaningSession "1" *-- "1" AuditLog : records to
|
|
252
|
+
CleaningSession "1" o-- "0..*" Issue : holds
|
|
253
|
+
BaseDetector ..> Issue : creates
|
|
254
|
+
BaseFixer ..> Issue : resolves
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
The UML class diagram is in [`docs/UML_class_diagram.mmd`](docs/UML_class_diagram.mmd)
|
|
258
|
+
(Mermaid). A full walkthrough is in [`demo.ipynb`](demo.ipynb).
|
|
259
|
+
|
|
260
|
+
## Project layout
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
MendData/
|
|
264
|
+
├── MendData/ the Python package
|
|
265
|
+
├── tests/ unit tests (pytest)
|
|
266
|
+
├── docs/ UML diagram and team contract
|
|
267
|
+
├── demo.ipynb worked example
|
|
268
|
+
├── setup.py
|
|
269
|
+
└── requirements.txt
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Running the tests
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
pip install pytest
|
|
276
|
+
pytest
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Team
|
|
280
|
+
|
|
281
|
+
| Member | Module |
|
|
282
|
+
|--------|--------|
|
|
283
|
+
| Ana Lynica B. Ferolino | `issue.py`, `session.py`, `utils.py`, `__init__.py`, documentation |
|
|
284
|
+
| Joner D. Jusol | `detectors.py`, packaging |
|
|
285
|
+
| Angeline B. Coniendo | `fixers.py`, UML diagram |
|
|
286
|
+
| Janel P. Obrador | `scoring.py`, `audit.py` |
|
|
287
|
+
|
|
288
|
+
## License
|
|
289
|
+
|
|
290
|
+
MIT. See [`LICENSE`](LICENSE).
|
|
291
|
+
classDiagram
|
|
292
|
+
direction TB
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
MendData/__init__.py,sha256=26rc90ruXNeR4j2A3kHNsrM1eCx52x77bI4E9V_5DPc,4831
|
|
2
|
+
MendData/audit.py,sha256=hYV2zTKGc1r-V3veHr_DirHzxkMfMlKCQgsfxINpdv8,4091
|
|
3
|
+
MendData/detectors.py,sha256=97FAo4c2OYBfCw-Iez87CiZd0I4nylzPSj2_zqOQj0I,13768
|
|
4
|
+
MendData/fixers.py,sha256=DZDV6tis5SxNet5YSXMd20sBAL6e6cJRXWq9pnZPqWA,17327
|
|
5
|
+
MendData/issue.py,sha256=goZdBI7Ub7swQtKFrBo443FLptQxWICRVMApY0iXIMA,9420
|
|
6
|
+
MendData/scoring.py,sha256=pfdkSiVQ03DGyL0xPMF-OEEhptGMWWXOLambqnUpU-Q,6353
|
|
7
|
+
MendData/session.py,sha256=yE1D-ulduE7ARr4v7dg56VIO7FapM4UOmVrEWma1O4M,18602
|
|
8
|
+
MendData/utils.py,sha256=90Ec9n2AISpec8Gp9zUe-oRKKNwUcTs_pw_jFmo5mTY,2586
|
|
9
|
+
menddata-0.1.0.dist-info/licenses/LICENSE,sha256=yYpnqyqGd3q0zRxW4Q9LPPrUwqIybt98eudTp9fPBX4,1100
|
|
10
|
+
menddata-0.1.0.dist-info/METADATA,sha256=J1LwYPYs5kPawPgIlav2zX2F-MoNxNE8p8DN1Tk8Qwk,8680
|
|
11
|
+
menddata-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
12
|
+
menddata-0.1.0.dist-info/top_level.txt,sha256=V5gvoPI811CSFtQsdJn2JAoH74MCc8XwGtdl9308VBI,9
|
|
13
|
+
menddata-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ana Lynica B. Ferolino
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
MendData
|