ds-proj-cc 0.1.3__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.
- ds_proj_cc-0.1.3/.github/workflows/ci.yml +28 -0
- ds_proj_cc-0.1.3/.github/workflows/release.yml +80 -0
- ds_proj_cc-0.1.3/.gitignore +10 -0
- ds_proj_cc-0.1.3/.python-version +1 -0
- ds_proj_cc-0.1.3/LICENSE +22 -0
- ds_proj_cc-0.1.3/PKG-INFO +51 -0
- ds_proj_cc-0.1.3/README.md +31 -0
- ds_proj_cc-0.1.3/pyproject.toml +40 -0
- ds_proj_cc-0.1.3/src/ds_proj_cc/__init__.py +248 -0
- ds_proj_cc-0.1.3/src/ds_proj_cc/py.typed +0 -0
- ds_proj_cc-0.1.3/tests/test_profiler.py +97 -0
- ds_proj_cc-0.1.3/uv.lock +79 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
strategy:
|
|
11
|
+
matrix:
|
|
12
|
+
python-version: ['3.11', '3.12', '3.13']
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Install uv
|
|
17
|
+
uses: astral-sh/setup-uv@v7
|
|
18
|
+
with:
|
|
19
|
+
enable-cache: true
|
|
20
|
+
|
|
21
|
+
- name: Install Python
|
|
22
|
+
run: uv python install ${{ matrix.python-version }}
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: uv sync --all-groups
|
|
26
|
+
|
|
27
|
+
- name: Run tests
|
|
28
|
+
run: uv run pytest -v
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*' # v0.1.0, v1.2.3, ...
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
name: Build distribution
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: Install uv
|
|
16
|
+
uses: astral-sh/setup-uv@v7
|
|
17
|
+
with:
|
|
18
|
+
enable-cache: true
|
|
19
|
+
|
|
20
|
+
- name: Set up Python
|
|
21
|
+
run: uv python install 3.13
|
|
22
|
+
|
|
23
|
+
- name: Build
|
|
24
|
+
run: uv build
|
|
25
|
+
|
|
26
|
+
- name: Smoke test (wheel)
|
|
27
|
+
run: uv run --isolated --no-project --with dist/*.whl python -c "from ds_proj_cc import profile; print(profile([{'name':'Alice','age':21},{'name':'Bob','age':22}])['rows'])"
|
|
28
|
+
|
|
29
|
+
- name: Upload dist/
|
|
30
|
+
uses: actions/upload-artifact@v4
|
|
31
|
+
with:
|
|
32
|
+
name: dist
|
|
33
|
+
path: dist/
|
|
34
|
+
|
|
35
|
+
publish-testpypi:
|
|
36
|
+
name: Publish to TestPyPI
|
|
37
|
+
needs: build
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
environment:
|
|
40
|
+
name: testpypi
|
|
41
|
+
url: https://test.pypi.org/project/ds-proj-cc/
|
|
42
|
+
permissions:
|
|
43
|
+
id-token: write
|
|
44
|
+
steps:
|
|
45
|
+
- name: Checkout
|
|
46
|
+
uses: actions/checkout@v4
|
|
47
|
+
|
|
48
|
+
- name: Download dist/
|
|
49
|
+
uses: actions/download-artifact@v4
|
|
50
|
+
with:
|
|
51
|
+
name: dist
|
|
52
|
+
path: dist/
|
|
53
|
+
|
|
54
|
+
- name: Install uv
|
|
55
|
+
uses: astral-sh/setup-uv@v7
|
|
56
|
+
|
|
57
|
+
- name: Publish
|
|
58
|
+
run: uv publish --index testpypi dist/*
|
|
59
|
+
|
|
60
|
+
publish-pypi:
|
|
61
|
+
name: Publish to PyPI
|
|
62
|
+
needs: publish-testpypi
|
|
63
|
+
runs-on: ubuntu-latest
|
|
64
|
+
environment:
|
|
65
|
+
name: pypi
|
|
66
|
+
url: https://pypi.org/project/ds-proj-cc/
|
|
67
|
+
permissions:
|
|
68
|
+
id-token: write
|
|
69
|
+
steps:
|
|
70
|
+
- name: Download dist/
|
|
71
|
+
uses: actions/download-artifact@v4
|
|
72
|
+
with:
|
|
73
|
+
name: dist
|
|
74
|
+
path: dist/
|
|
75
|
+
|
|
76
|
+
- name: Install uv
|
|
77
|
+
uses: astral-sh/setup-uv@v7
|
|
78
|
+
|
|
79
|
+
- name: Publish
|
|
80
|
+
run: uv publish dist/*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
ds_proj_cc-0.1.3/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Chirantan Chakraborty
|
|
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.
|
|
22
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ds-proj-cc
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: A lightweight dataset profiling toolkit
|
|
5
|
+
Project-URL: Homepage, https://github.com/WeiWuxian0609/ds-proj-cc
|
|
6
|
+
Project-URL: Issues, https://github.com/WeiWuxian0609/ds-proj-cc/issues
|
|
7
|
+
Author-email: Chirantan Chakraborty <cchirantan1@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: dataset profiler,tds
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Education
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# ds-proj-cc
|
|
22
|
+
|
|
23
|
+
**DS Profiler**
|
|
24
|
+
|
|
25
|
+
A lightweight Python toolkit for *dataset profiling, statistical summaries, missing-value detection, duplicate detection, and numerical anomaly detection.*
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install ds-proj-cc
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from ds_proj_cc import profile, summarize, detect_anomalies
|
|
37
|
+
|
|
38
|
+
data = [
|
|
39
|
+
{"name": "Alice", "age": 21, "score": 85},
|
|
40
|
+
{"name": "Bob", "age": 22, "score": 91},
|
|
41
|
+
{"name": "Charlie", "age": None, "score": 78},
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
print(profile(data))
|
|
45
|
+
print(summarize(data))
|
|
46
|
+
print(detect_anomalies(data))
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Author
|
|
50
|
+
|
|
51
|
+
**Chirantan Chakraborty**
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# ds-proj-cc
|
|
2
|
+
|
|
3
|
+
**DS Profiler**
|
|
4
|
+
|
|
5
|
+
A lightweight Python toolkit for *dataset profiling, statistical summaries, missing-value detection, duplicate detection, and numerical anomaly detection.*
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install ds-proj-cc
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from ds_proj_cc import profile, summarize, detect_anomalies
|
|
17
|
+
|
|
18
|
+
data = [
|
|
19
|
+
{"name": "Alice", "age": 21, "score": 85},
|
|
20
|
+
{"name": "Bob", "age": 22, "score": 91},
|
|
21
|
+
{"name": "Charlie", "age": None, "score": 78},
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
print(profile(data))
|
|
25
|
+
print(summarize(data))
|
|
26
|
+
print(detect_anomalies(data))
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Author
|
|
30
|
+
|
|
31
|
+
**Chirantan Chakraborty**
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "ds-proj-cc"
|
|
3
|
+
version = "0.1.3"
|
|
4
|
+
description = "A lightweight dataset profiling toolkit"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
authors = [
|
|
8
|
+
{ name = "Chirantan Chakraborty", email = "cchirantan1@gmail.com" }
|
|
9
|
+
]
|
|
10
|
+
keywords = ["tds", "dataset profiler"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 3 - Alpha",
|
|
13
|
+
"License :: OSI Approved :: MIT License",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
16
|
+
"Programming Language :: Python :: 3.11",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
18
|
+
"Programming Language :: Python :: 3.13",
|
|
19
|
+
"Topic :: Education",
|
|
20
|
+
]
|
|
21
|
+
dependencies = []
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://github.com/WeiWuxian0609/ds-proj-cc"
|
|
25
|
+
Issues = "https://github.com/WeiWuxian0609/ds-proj-cc/issues"
|
|
26
|
+
|
|
27
|
+
[build-system]
|
|
28
|
+
requires = ["hatchling"]
|
|
29
|
+
build-backend = "hatchling.build"
|
|
30
|
+
|
|
31
|
+
[[tool.uv.index]]
|
|
32
|
+
name = "testpypi"
|
|
33
|
+
url = "https://test.pypi.org/simple/"
|
|
34
|
+
publish-url = "https://test.pypi.org/legacy/"
|
|
35
|
+
explicit = true
|
|
36
|
+
|
|
37
|
+
[dependency-groups]
|
|
38
|
+
dev = [
|
|
39
|
+
"pytest>=9.1.1",
|
|
40
|
+
]
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ds_proj_cc — a lightweight dataset profiling toolkit.
|
|
3
|
+
|
|
4
|
+
Provides utilities for inspecting tabular data, including:
|
|
5
|
+
- Dataset dimensions
|
|
6
|
+
- Missing values
|
|
7
|
+
- Duplicate rows
|
|
8
|
+
- Column names
|
|
9
|
+
- Basic numerical statistics
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from importlib.metadata import version as _v
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
import csv
|
|
15
|
+
import statistics
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
__version__ = _v("ds-proj-cc")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _load_csv(path: str) -> list[dict]:
|
|
22
|
+
"""Load a CSV file into a list of dictionaries."""
|
|
23
|
+
|
|
24
|
+
file_path = Path(path)
|
|
25
|
+
|
|
26
|
+
if not file_path.exists():
|
|
27
|
+
raise FileNotFoundError(f"File not found: {path}")
|
|
28
|
+
|
|
29
|
+
if not file_path.is_file():
|
|
30
|
+
raise ValueError(f"Not a file: {path}")
|
|
31
|
+
|
|
32
|
+
with file_path.open("r", newline="", encoding="utf-8") as file:
|
|
33
|
+
return list(csv.DictReader(file))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _validate_data(data: list[dict]) -> None:
|
|
37
|
+
"""Validate dataset structure."""
|
|
38
|
+
|
|
39
|
+
if not isinstance(data, list):
|
|
40
|
+
raise TypeError("data must be a list")
|
|
41
|
+
|
|
42
|
+
if not all(isinstance(row, dict) for row in data):
|
|
43
|
+
raise TypeError("each row must be a dictionary")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _prepare_data(data_or_path) -> list[dict]:
|
|
47
|
+
"""Accept either a list of dictionaries or a CSV path."""
|
|
48
|
+
|
|
49
|
+
if isinstance(data_or_path, (str, Path)):
|
|
50
|
+
return _load_csv(str(data_or_path))
|
|
51
|
+
|
|
52
|
+
_validate_data(data_or_path)
|
|
53
|
+
return data_or_path
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def profile(data_or_path) -> dict:
|
|
57
|
+
"""
|
|
58
|
+
Generate a statistical profile of a tabular dataset.
|
|
59
|
+
|
|
60
|
+
Parameters
|
|
61
|
+
----------
|
|
62
|
+
data_or_path:
|
|
63
|
+
Either:
|
|
64
|
+
- a list of dictionaries, or
|
|
65
|
+
- a path to a CSV file.
|
|
66
|
+
|
|
67
|
+
Returns
|
|
68
|
+
-------
|
|
69
|
+
dict
|
|
70
|
+
Dataset statistics.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
data = _prepare_data(data_or_path)
|
|
74
|
+
|
|
75
|
+
if not data:
|
|
76
|
+
return {
|
|
77
|
+
"rows": 0,
|
|
78
|
+
"columns": 0,
|
|
79
|
+
"missing_values": 0,
|
|
80
|
+
"duplicate_rows": 0,
|
|
81
|
+
"column_names": [],
|
|
82
|
+
"numerical_summary": {},
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# Collect all column names.
|
|
86
|
+
columns = set()
|
|
87
|
+
|
|
88
|
+
for row in data:
|
|
89
|
+
columns.update(row.keys())
|
|
90
|
+
|
|
91
|
+
columns = sorted(columns)
|
|
92
|
+
|
|
93
|
+
# Count missing values.
|
|
94
|
+
missing_values = sum(
|
|
95
|
+
1
|
|
96
|
+
for row in data
|
|
97
|
+
for column in columns
|
|
98
|
+
if row.get(column) in (None, "")
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
# Count duplicate rows.
|
|
102
|
+
row_signatures = [
|
|
103
|
+
tuple(sorted(row.items()))
|
|
104
|
+
for row in data
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
duplicate_rows = len(data) - len(set(row_signatures))
|
|
108
|
+
|
|
109
|
+
# Numerical statistics.
|
|
110
|
+
numerical_summary = {}
|
|
111
|
+
|
|
112
|
+
for column in columns:
|
|
113
|
+
values = []
|
|
114
|
+
|
|
115
|
+
for row in data:
|
|
116
|
+
value = row.get(column)
|
|
117
|
+
|
|
118
|
+
if value in (None, ""):
|
|
119
|
+
continue
|
|
120
|
+
|
|
121
|
+
try:
|
|
122
|
+
values.append(float(value))
|
|
123
|
+
except (ValueError, TypeError):
|
|
124
|
+
pass
|
|
125
|
+
|
|
126
|
+
if values:
|
|
127
|
+
numerical_summary[column] = {
|
|
128
|
+
"count": len(values),
|
|
129
|
+
"mean": round(statistics.mean(values), 2),
|
|
130
|
+
"median": round(statistics.median(values), 2),
|
|
131
|
+
"minimum": min(values),
|
|
132
|
+
"maximum": max(values),
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
"rows": len(data),
|
|
137
|
+
"columns": len(columns),
|
|
138
|
+
"missing_values": missing_values,
|
|
139
|
+
"duplicate_rows": duplicate_rows,
|
|
140
|
+
"column_names": columns,
|
|
141
|
+
"numerical_summary": numerical_summary,
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def summarize(data_or_path) -> str:
|
|
146
|
+
"""
|
|
147
|
+
Generate a human-readable dataset summary.
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
result = profile(data_or_path)
|
|
151
|
+
|
|
152
|
+
lines = [
|
|
153
|
+
"Dataset Profile",
|
|
154
|
+
"────────────────────────────",
|
|
155
|
+
f"Rows: {result['rows']}",
|
|
156
|
+
f"Columns: {result['columns']}",
|
|
157
|
+
f"Missing values: {result['missing_values']}",
|
|
158
|
+
f"Duplicate rows: {result['duplicate_rows']}",
|
|
159
|
+
"",
|
|
160
|
+
"Columns",
|
|
161
|
+
"────────────────────────────",
|
|
162
|
+
]
|
|
163
|
+
|
|
164
|
+
for column in result["column_names"]:
|
|
165
|
+
lines.append(f"- {column}")
|
|
166
|
+
|
|
167
|
+
if result["numerical_summary"]:
|
|
168
|
+
lines.extend([
|
|
169
|
+
"",
|
|
170
|
+
"Numerical Summary",
|
|
171
|
+
"────────────────────────────",
|
|
172
|
+
])
|
|
173
|
+
|
|
174
|
+
for column, stats in result["numerical_summary"].items():
|
|
175
|
+
lines.extend([
|
|
176
|
+
f"{column}:",
|
|
177
|
+
f" Count: {stats['count']}",
|
|
178
|
+
f" Mean: {stats['mean']}",
|
|
179
|
+
f" Median: {stats['median']}",
|
|
180
|
+
f" Min: {stats['minimum']}",
|
|
181
|
+
f" Max: {stats['maximum']}",
|
|
182
|
+
])
|
|
183
|
+
|
|
184
|
+
return "\n".join(lines)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def detect_anomalies(data_or_path) -> dict:
|
|
188
|
+
"""
|
|
189
|
+
Detect simple anomalies in numerical columns.
|
|
190
|
+
|
|
191
|
+
Uses the IQR (Interquartile Range) method.
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
data = _prepare_data(data_or_path)
|
|
195
|
+
|
|
196
|
+
if not data:
|
|
197
|
+
return {}
|
|
198
|
+
|
|
199
|
+
columns = set()
|
|
200
|
+
|
|
201
|
+
for row in data:
|
|
202
|
+
columns.update(row.keys())
|
|
203
|
+
|
|
204
|
+
anomalies = {}
|
|
205
|
+
|
|
206
|
+
for column in sorted(columns):
|
|
207
|
+
|
|
208
|
+
values = []
|
|
209
|
+
|
|
210
|
+
for row in data:
|
|
211
|
+
value = row.get(column)
|
|
212
|
+
|
|
213
|
+
if value in (None, ""):
|
|
214
|
+
continue
|
|
215
|
+
|
|
216
|
+
try:
|
|
217
|
+
values.append(float(value))
|
|
218
|
+
except (ValueError, TypeError):
|
|
219
|
+
continue
|
|
220
|
+
|
|
221
|
+
if len(values) < 4:
|
|
222
|
+
continue
|
|
223
|
+
|
|
224
|
+
values.sort()
|
|
225
|
+
|
|
226
|
+
q1 = statistics.quantiles(values, n=4)[0]
|
|
227
|
+
q3 = statistics.quantiles(values, n=4)[2]
|
|
228
|
+
|
|
229
|
+
iqr = q3 - q1
|
|
230
|
+
|
|
231
|
+
lower_bound = q1 - 1.5 * iqr
|
|
232
|
+
upper_bound = q3 + 1.5 * iqr
|
|
233
|
+
|
|
234
|
+
outliers = [
|
|
235
|
+
value
|
|
236
|
+
for value in values
|
|
237
|
+
if value < lower_bound or value > upper_bound
|
|
238
|
+
]
|
|
239
|
+
|
|
240
|
+
if outliers:
|
|
241
|
+
anomalies[column] = {
|
|
242
|
+
"outliers": outliers,
|
|
243
|
+
"count": len(outliers),
|
|
244
|
+
"lower_bound": round(lower_bound, 2),
|
|
245
|
+
"upper_bound": round(upper_bound, 2),
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return anomalies
|
|
File without changes
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from ds_proj_cc import profile, summarize, detect_anomalies
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_profile_basic_dataset():
|
|
7
|
+
data = [
|
|
8
|
+
{"name": "Alice", "age": 21},
|
|
9
|
+
{"name": "Bob", "age": 22},
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
result = profile(data)
|
|
13
|
+
|
|
14
|
+
assert result["rows"] == 2
|
|
15
|
+
assert result["columns"] == 2
|
|
16
|
+
assert result["missing_values"] == 0
|
|
17
|
+
assert result["duplicate_rows"] == 0
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_profile_missing_values():
|
|
21
|
+
data = [
|
|
22
|
+
{"name": "Alice", "age": 21},
|
|
23
|
+
{"name": "Bob", "age": None},
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
result = profile(data)
|
|
27
|
+
|
|
28
|
+
assert result["missing_values"] == 1
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_profile_duplicate_rows():
|
|
32
|
+
data = [
|
|
33
|
+
{"name": "Alice", "age": 21},
|
|
34
|
+
{"name": "Alice", "age": 21},
|
|
35
|
+
{"name": "Bob", "age": 22},
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
result = profile(data)
|
|
39
|
+
|
|
40
|
+
assert result["duplicate_rows"] == 1
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_numerical_summary():
|
|
44
|
+
data = [
|
|
45
|
+
{"name": "Alice", "score": 80},
|
|
46
|
+
{"name": "Bob", "score": 90},
|
|
47
|
+
{"name": "Charlie", "score": 100},
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
result = profile(data)
|
|
51
|
+
|
|
52
|
+
assert result["numerical_summary"]["score"]["mean"] == 90.0
|
|
53
|
+
assert result["numerical_summary"]["score"]["median"] == 90.0
|
|
54
|
+
assert result["numerical_summary"]["score"]["minimum"] == 80.0
|
|
55
|
+
assert result["numerical_summary"]["score"]["maximum"] == 100.0
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_summarize():
|
|
59
|
+
data = [
|
|
60
|
+
{"name": "Alice", "age": 21},
|
|
61
|
+
{"name": "Bob", "age": 22},
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
result = summarize(data)
|
|
65
|
+
|
|
66
|
+
assert "Dataset Profile" in result
|
|
67
|
+
assert "Rows:" in result
|
|
68
|
+
assert "Columns:" in result
|
|
69
|
+
|
|
70
|
+
def test_anomaly_detection():
|
|
71
|
+
data = [
|
|
72
|
+
{"score": 10},
|
|
73
|
+
{"score": 11},
|
|
74
|
+
{"score": 12},
|
|
75
|
+
{"score": 13},
|
|
76
|
+
{"score": 12},
|
|
77
|
+
{"score": 11},
|
|
78
|
+
{"score": 13},
|
|
79
|
+
{"score": 12},
|
|
80
|
+
{"score": 11},
|
|
81
|
+
{"score": 100},
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
result = detect_anomalies(data)
|
|
85
|
+
|
|
86
|
+
assert "score" in result
|
|
87
|
+
assert 100.0 in result["score"]["outliers"]
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def test_invalid_file_path():
|
|
91
|
+
with pytest.raises(FileNotFoundError):
|
|
92
|
+
profile("not a dataset")
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def test_invalid_row_type():
|
|
96
|
+
with pytest.raises(TypeError):
|
|
97
|
+
profile([{"name": "Alice"}, "invalid row"])
|
ds_proj_cc-0.1.3/uv.lock
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
version = 1
|
|
2
|
+
revision = 2
|
|
3
|
+
requires-python = ">=3.13"
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "colorama"
|
|
7
|
+
version = "0.4.6"
|
|
8
|
+
source = { registry = "https://pypi.org/simple" }
|
|
9
|
+
sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" }
|
|
10
|
+
wheels = [
|
|
11
|
+
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[[package]]
|
|
15
|
+
name = "ds-proj-cc"
|
|
16
|
+
version = "0.1.3"
|
|
17
|
+
source = { editable = "." }
|
|
18
|
+
|
|
19
|
+
[package.dev-dependencies]
|
|
20
|
+
dev = [
|
|
21
|
+
{ name = "pytest" },
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[package.metadata]
|
|
25
|
+
|
|
26
|
+
[package.metadata.requires-dev]
|
|
27
|
+
dev = [{ name = "pytest", specifier = ">=9.1.1" }]
|
|
28
|
+
|
|
29
|
+
[[package]]
|
|
30
|
+
name = "iniconfig"
|
|
31
|
+
version = "2.3.0"
|
|
32
|
+
source = { registry = "https://pypi.org/simple" }
|
|
33
|
+
sdist = { url = "https://files.pythonhosted.org/packages/72/34/14ca021ce8e5dfedc35312d08ba8bf51fdd999c576889fc2c24cb97f4f10/iniconfig-2.3.0.tar.gz", hash = "sha256:c76315c77db068650d49c5b56314774a7804df16fee4402c1f19d6d15d8c4730", size = 20503, upload-time = "2025-10-18T21:55:43.219Z" }
|
|
34
|
+
wheels = [
|
|
35
|
+
{ url = "https://files.pythonhosted.org/packages/cb/b1/3846dd7f199d53cb17f49cba7e651e9ce294d8497c8c150530ed11865bb8/iniconfig-2.3.0-py3-none-any.whl", hash = "sha256:f631c04d2c48c52b84d0d0549c99ff3859c98df65b3101406327ecc7d53fbf12", size = 7484, upload-time = "2025-10-18T21:55:41.639Z" },
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[[package]]
|
|
39
|
+
name = "packaging"
|
|
40
|
+
version = "26.3"
|
|
41
|
+
source = { registry = "https://pypi.org/simple" }
|
|
42
|
+
sdist = { url = "https://files.pythonhosted.org/packages/7d/fa/3944b40b07da9ce895c0e6303a5ab7d53da063554f534556b134a54d6093/packaging-26.3.tar.gz", hash = "sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79", size = 313412, upload-time = "2026-08-04T18:15:28.737Z" }
|
|
43
|
+
wheels = [
|
|
44
|
+
{ url = "https://files.pythonhosted.org/packages/63/34/ba1c580383c9eada3711951fef0795c80b829a078d72188184bcab9dd527/packaging-26.3-py3-none-any.whl", hash = "sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c", size = 129956, upload-time = "2026-08-04T18:15:27.159Z" },
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[[package]]
|
|
48
|
+
name = "pluggy"
|
|
49
|
+
version = "1.6.0"
|
|
50
|
+
source = { registry = "https://pypi.org/simple" }
|
|
51
|
+
sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412, upload-time = "2025-05-15T12:30:07.975Z" }
|
|
52
|
+
wheels = [
|
|
53
|
+
{ url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" },
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
[[package]]
|
|
57
|
+
name = "pygments"
|
|
58
|
+
version = "2.21.0"
|
|
59
|
+
source = { registry = "https://pypi.org/simple" }
|
|
60
|
+
sdist = { url = "https://files.pythonhosted.org/packages/49/2e/ced460408999b33da6b31b0021b0f37d329e202d4169aeb164493778f25b/pygments-2.21.0.tar.gz", hash = "sha256:610ca751c9bc2492b38eb9a38a7fbc93edbbb2d7182edaf34e66ae493dee5c8c", size = 5005329, upload-time = "2026-08-17T08:02:48.824Z" }
|
|
61
|
+
wheels = [
|
|
62
|
+
{ url = "https://files.pythonhosted.org/packages/71/46/17f022dd3e953bf20a04a028a21ec746d942f8d2af30fa0f124fa0e6a684/pygments-2.21.0-py3-none-any.whl", hash = "sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9", size = 1250147, upload-time = "2026-08-17T08:02:44.912Z" },
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
[[package]]
|
|
66
|
+
name = "pytest"
|
|
67
|
+
version = "9.1.1"
|
|
68
|
+
source = { registry = "https://pypi.org/simple" }
|
|
69
|
+
dependencies = [
|
|
70
|
+
{ name = "colorama", marker = "sys_platform == 'win32'" },
|
|
71
|
+
{ name = "iniconfig" },
|
|
72
|
+
{ name = "packaging" },
|
|
73
|
+
{ name = "pluggy" },
|
|
74
|
+
{ name = "pygments" },
|
|
75
|
+
]
|
|
76
|
+
sdist = { url = "https://files.pythonhosted.org/packages/e4/47/b9efed96c114afcfa3c9d3fe98a76a1d14c74a9e266d397cf6eb64be5e01/pytest-9.1.1.tar.gz", hash = "sha256:1088fbde8f2b49d95a549a195707afa7a76a3ce9bcadc26b6d71f0ffda5fe313", size = 1636369, upload-time = "2026-06-19T10:58:32.857Z" }
|
|
77
|
+
wheels = [
|
|
78
|
+
{ url = "https://files.pythonhosted.org/packages/24/25/1de2678b631f5a49215c6c96fff41ba892b0a34df68d6d80292b1b48aa7f/pytest-9.1.1-py3-none-any.whl", hash = "sha256:37a86b45efb9a47a61a36449063e8e18d0cab3161329fc099eb21783169c4f0c", size = 386536, upload-time = "2026-06-19T10:58:31.347Z" },
|
|
79
|
+
]
|