dva-lab 0.1.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.
- dva_lab-0.1.0/LICENSE +21 -0
- dva_lab-0.1.0/PKG-INFO +292 -0
- dva_lab-0.1.0/README.md +242 -0
- dva_lab-0.1.0/pyproject.toml +89 -0
- dva_lab-0.1.0/setup.cfg +4 -0
- dva_lab-0.1.0/src/dva_lab/__init__.py +87 -0
- dva_lab-0.1.0/src/dva_lab/core.py +364 -0
- dva_lab-0.1.0/src/dva_lab/data/sales_data.csv +11 -0
- dva_lab-0.1.0/src/dva_lab/experiments/__init__.py +53 -0
- dva_lab-0.1.0/src/dva_lab/experiments/base.py +43 -0
- dva_lab-0.1.0/src/dva_lab/experiments/exp01_olap.py +187 -0
- dva_lab-0.1.0/src/dva_lab/experiments/exp02_star_schema.py +270 -0
- dva_lab-0.1.0/src/dva_lab/experiments/exp03_bar_charts.py +166 -0
- dva_lab-0.1.0/src/dva_lab/experiments/exp04_grouped_stacked.py +195 -0
- dva_lab-0.1.0/src/dva_lab/experiments/exp05_histograms.py +164 -0
- dva_lab-0.1.0/src/dva_lab/experiments/exp06_density.py +166 -0
- dva_lab-0.1.0/src/dva_lab/experiments/exp07_ecdf.py +116 -0
- dva_lab-0.1.0/src/dva_lab/experiments/exp08_qq_plot.py +113 -0
- dva_lab-0.1.0/src/dva_lab/experiments/exp09_scatter.py +109 -0
- dva_lab-0.1.0/src/dva_lab/experiments/exp10_powerbi_visualization.py +166 -0
- dva_lab-0.1.0/src/dva_lab/experiments/exp11_powerbi_dax.py +167 -0
- dva_lab-0.1.0/src/dva_lab/experiments/exp12_powerbi_logic.py +179 -0
- dva_lab-0.1.0/src/dva_lab/registry.py +109 -0
- dva_lab-0.1.0/src/dva_lab.egg-info/PKG-INFO +292 -0
- dva_lab-0.1.0/src/dva_lab.egg-info/SOURCES.txt +28 -0
- dva_lab-0.1.0/src/dva_lab.egg-info/dependency_links.txt +1 -0
- dva_lab-0.1.0/src/dva_lab.egg-info/requires.txt +27 -0
- dva_lab-0.1.0/src/dva_lab.egg-info/top_level.txt +1 -0
- dva_lab-0.1.0/tests/test_experiments.py +228 -0
- dva_lab-0.1.0/tests/test_registry.py +77 -0
dva_lab-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DVA Lab Contributors
|
|
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.
|
dva_lab-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dva-lab
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python package for Data Visualization and Analytics (DVA) laboratory experiments in Jupyter Notebook.
|
|
5
|
+
Author-email: DVA Lab Team <dva-lab@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/AnandChowdari/dva-lab
|
|
8
|
+
Project-URL: Repository, https://github.com/AnandChowdari/dva-lab.git
|
|
9
|
+
Project-URL: Issues, https://github.com/AnandChowdari/dva-lab/issues
|
|
10
|
+
Keywords: data-visualization,analytics,dva,jupyter,matplotlib,seaborn,powerbi,olap,sql
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
21
|
+
Classifier: Framework :: Jupyter
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: matplotlib>=3.5.0
|
|
26
|
+
Requires-Dist: numpy>=1.20.0
|
|
27
|
+
Requires-Dist: seaborn>=0.12.0
|
|
28
|
+
Requires-Dist: scipy>=1.7.0
|
|
29
|
+
Requires-Dist: statsmodels>=0.13.0
|
|
30
|
+
Requires-Dist: pandas>=1.3.0
|
|
31
|
+
Provides-Extra: viz
|
|
32
|
+
Requires-Dist: matplotlib>=3.5.0; extra == "viz"
|
|
33
|
+
Requires-Dist: numpy>=1.20.0; extra == "viz"
|
|
34
|
+
Requires-Dist: seaborn>=0.12.0; extra == "viz"
|
|
35
|
+
Requires-Dist: scipy>=1.7.0; extra == "viz"
|
|
36
|
+
Requires-Dist: statsmodels>=0.13.0; extra == "viz"
|
|
37
|
+
Provides-Extra: full
|
|
38
|
+
Requires-Dist: dva-lab[viz]; extra == "full"
|
|
39
|
+
Requires-Dist: pandas>=1.3.0; extra == "full"
|
|
40
|
+
Requires-Dist: ipython>=8.0.0; extra == "full"
|
|
41
|
+
Provides-Extra: test
|
|
42
|
+
Requires-Dist: pytest>=7.0.0; extra == "test"
|
|
43
|
+
Requires-Dist: matplotlib>=3.5.0; extra == "test"
|
|
44
|
+
Requires-Dist: numpy>=1.20.0; extra == "test"
|
|
45
|
+
Requires-Dist: seaborn>=0.12.0; extra == "test"
|
|
46
|
+
Requires-Dist: scipy>=1.7.0; extra == "test"
|
|
47
|
+
Requires-Dist: statsmodels>=0.13.0; extra == "test"
|
|
48
|
+
Requires-Dist: pandas>=1.3.0; extra == "test"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
# ๐ `dva-lab` โ Data Visualization & Analytics Laboratory Library
|
|
52
|
+
|
|
53
|
+
[](https://www.python.org/)
|
|
54
|
+
[](LICENSE)
|
|
55
|
+
[](https://jupyter.org/)
|
|
56
|
+
[]()
|
|
57
|
+
|
|
58
|
+
**`dva-lab`** is an installable, self-contained Python library engineered for university students and educators. It enables students to retrieve, display, study, and execute all 12 Data Visualization and Analytics (DVA) laboratory experiments directly inside **Jupyter Notebook**, **JupyterLab**, or **Google Colab**.
|
|
59
|
+
|
|
60
|
+
The package stores the complete, authoritative source code, schemas, and datasets locally within the library. It does not depend on fetching code from the internet during runtime.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## ๐ Table of Contents
|
|
65
|
+
|
|
66
|
+
- [Features](#-features)
|
|
67
|
+
- [Installation](#-installation)
|
|
68
|
+
- [Google Colab & Jupyter Notebook](#google-colab--jupyter-notebook)
|
|
69
|
+
- [Local Development & Pip](#local-development--pip)
|
|
70
|
+
- [Optional Dependency Sets](#optional-dependency-sets)
|
|
71
|
+
- [Quick Start](#-quick-start)
|
|
72
|
+
- [Complete Experiment Catalog](#-complete-experiment-catalog)
|
|
73
|
+
- [Public API Reference](#-public-api-reference)
|
|
74
|
+
- [Experiment Execution Guidelines](#-experiment-execution-guidelines)
|
|
75
|
+
- [SQL & OLAP Experiments (Exp 1 & 2)](#1-sql--olap-experiments-experiments-1-and-2)
|
|
76
|
+
- [Python Plotting Experiments (Exp 3 to 9)](#2-python-plotting-experiments-experiments-3-to-9)
|
|
77
|
+
- [Power BI & DAX Experiments (Exp 10 to 12)](#3-power-bi--dax-experiments-experiments-10-to-12)
|
|
78
|
+
- [Updating & Uninstalling](#-updating--uninstalling)
|
|
79
|
+
- [Contributing](#-contributing)
|
|
80
|
+
- [License](#-license)
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## ๐ Features
|
|
85
|
+
|
|
86
|
+
- **Jupyter-Native Experience**: Seamless inline rendering of Matplotlib/Seaborn plots and rich HTML/Markdown experiment guides.
|
|
87
|
+
- **Self-Contained & Deterministic**: Bundles all source code, SQL definitions, Power BI DAX expressions, and sample datasets (`sales_data.csv`).
|
|
88
|
+
- **Reproducible Seeds**: Synthetic distributions use fixed random seeds (`seed=0`) matching laboratory manual benchmarks.
|
|
89
|
+
- **Safe & Non-Destructive**: Never connects to an unknown database without explicit authorization and never attempts mock Power BI execution.
|
|
90
|
+
- **Convenient Shortcuts**: Direct function handles (`dva_lab.exp1()` through `dva_lab.exp12()`) for fast classroom access.
|
|
91
|
+
- **Lightweight Core**: Base install contains zero compulsory heavy dependencies with lazy imports for plotting engines.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## ๐ฆ Installation
|
|
96
|
+
|
|
97
|
+
### Google Colab & Jupyter Notebook
|
|
98
|
+
|
|
99
|
+
Paste and execute directly in a notebook cell:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
# Install directly from GitHub with visualization dependencies
|
|
103
|
+
%pip install "dva-lab[viz] @ git+https://github.com/AnandChowdari/dva-lab.git"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
*Note: Replace `AnandChowdari` with your GitHub username or organization repository URL.*
|
|
107
|
+
|
|
108
|
+
### Local Development & Pip
|
|
109
|
+
|
|
110
|
+
#### Windows (PowerShell):
|
|
111
|
+
```powershell
|
|
112
|
+
git clone https://github.com/AnandChowdari/dva-lab.git
|
|
113
|
+
cd dva-lab
|
|
114
|
+
pip install -e .[viz]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### macOS / Linux:
|
|
118
|
+
```bash
|
|
119
|
+
git clone https://github.com/AnandChowdari/dva-lab.git
|
|
120
|
+
cd dva-lab
|
|
121
|
+
pip install -e ".[viz]"
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Optional Dependency Sets
|
|
125
|
+
|
|
126
|
+
| Group | Install Command | Included Packages | Purpose |
|
|
127
|
+
|---|---|---|---|
|
|
128
|
+
| **Base** | `pip install git+https://github.com/AnandChowdari/dva-lab.git` | Pure Python core | Code retrieval, schema inspection, CLI list |
|
|
129
|
+
| **`viz`** | `pip install "dva-lab[viz]"` | `matplotlib`, `numpy`, `seaborn`, `scipy`, `statsmodels` | Plotting experiments (Exp 3โ9) |
|
|
130
|
+
| **`full`** | `pip install "dva-lab[full]"` | `viz` + `pandas` + `ipython` | Full workbook with simulations & dataset tools |
|
|
131
|
+
| **`test`** | `pip install "dva-lab[test]"` | `viz` + `pandas` + `pytest` | Running the test suite locally |
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## โก Quick Start
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
import dva_lab
|
|
139
|
+
|
|
140
|
+
# 1. Discover all registered experiments
|
|
141
|
+
dva_lab.list_experiments()
|
|
142
|
+
|
|
143
|
+
# 2. Display formatted Markdown manual for Experiment 3
|
|
144
|
+
dva_lab.show_experiment(3)
|
|
145
|
+
|
|
146
|
+
# 3. Retrieve raw source code as a string
|
|
147
|
+
code = dva_lab.get_code(3)
|
|
148
|
+
print(code)
|
|
149
|
+
|
|
150
|
+
# 4. Execute experiment and render plots inline
|
|
151
|
+
dva_lab.exp3()
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## ๐ Complete Experiment Catalog
|
|
157
|
+
|
|
158
|
+
| # | Title | Category | Methodology / Tools | Focus |
|
|
159
|
+
|:---:|---|---|---|---|
|
|
160
|
+
| **1** | OLAP Operations Using Materialized Views | `OLAP & SQL` | PostgreSQL 12+, CUBE | Materialized view, Roll Up, Slice, Dice, Pivot |
|
|
161
|
+
| **2** | OLAP Operations Based on Star Schema | `OLAP & SQL` | PostgreSQL 12+, CUBE | Fact & dimension joins, Drill Down, Hierarchy |
|
|
162
|
+
| **3** | Vertical and Horizontal Bar Charts | `Python Visualization` | Matplotlib, NumPy | `plt.bar`, `plt.barh`, categorical comparison |
|
|
163
|
+
| **4** | Grouped and Stacked Bar Charts | `Python Visualization` | Matplotlib, NumPy | Positional offsets, stacked `bottom` vectors |
|
|
164
|
+
| **5** | Single & Multiple Variable Histograms | `Python Visualization` | Matplotlib, NumPy | Bin frequency, alpha transparency, normal distributions |
|
|
165
|
+
| **6** | Single & Multiple Variable Density Plots | `Python Visualization` | Seaborn, Matplotlib | Kernel Density Estimation (`sns.kdeplot`), area fills |
|
|
166
|
+
| **7** | Empirical Cumulative Distribution Function | `Python Visualization` | Statsmodels, Matplotlib | Non-parametric ECDF step function (`sm.distributions.ECDF`) |
|
|
167
|
+
| **8** | Q-Q Plot to Compare Datasets | `Python Visualization` | SciPy, Matplotlib | Normal probability quantiles (`stats.probplot`) |
|
|
168
|
+
| **9** | Scatter Plot Using Sample Data | `Python Visualization` | Matplotlib, NumPy | Bivariate scatter points, alpha blending, correlation |
|
|
169
|
+
| **10** | Power BI Sales Data Visualization | `Power BI` | Power BI Desktop, CSV | Column, Pie, Line, Card, Slicer dashboard |
|
|
170
|
+
| **11** | Power BI Calculations & DAX Measures | `Power BI` | DAX, Power BI Desktop | `Total Cost`, `Profit`, `CALCULATE`, `ALL`, percentages |
|
|
171
|
+
| **12** | Power BI Conditional & Logical Analysis | `Power BI` | DAX, Power BI Desktop | `IF`, `AND`, `OR`, `COUNTROWS`, dynamic sales tiers |
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## ๐ Public API Reference
|
|
176
|
+
|
|
177
|
+
### `dva_lab.list_experiments()`
|
|
178
|
+
Returns a rich `ExperimentList` containing all 12 experiments.
|
|
179
|
+
- **In Jupyter**: Automatically renders a styled HTML table with badges.
|
|
180
|
+
- **In Terminal**: Displays an aligned text summary.
|
|
181
|
+
- **Convert to DataFrame**: `dva_lab.list_experiments().to_dataframe()`
|
|
182
|
+
|
|
183
|
+
### `dva_lab.show_experiment(number: int)`
|
|
184
|
+
Displays the complete laboratory manual for the experiment:
|
|
185
|
+
- Experiment Aim
|
|
186
|
+
- Theoretical Concept & Pedagogical Context
|
|
187
|
+
- Complete, Corrected Input Code
|
|
188
|
+
- Expected Visual Output or Result Table
|
|
189
|
+
- Result Statement
|
|
190
|
+
- Execution Notes & Errata
|
|
191
|
+
|
|
192
|
+
### `dva_lab.get_code(number: int) -> str`
|
|
193
|
+
Returns the exact, clean source code string for inspection or programmatic export:
|
|
194
|
+
```python
|
|
195
|
+
with open("exp03.py", "w") as f:
|
|
196
|
+
f.write(dva_lab.get_code(3))
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### `dva_lab.run_experiment(number: int, **kwargs)`
|
|
200
|
+
Executes the specified experiment:
|
|
201
|
+
- For Python experiments (3โ9): Renders plots inline.
|
|
202
|
+
- Optional arguments:
|
|
203
|
+
- `show=True`: Call `plt.show()` inline.
|
|
204
|
+
- `side_by_side=True`: For multi-plot experiments (3, 4, 5, 6), combines subplots horizontally.
|
|
205
|
+
|
|
206
|
+
### Convenience Shortcuts (`dva_lab.exp1()` ... `dva_lab.exp12()`)
|
|
207
|
+
One-line helper functions to immediately access any experiment:
|
|
208
|
+
```python
|
|
209
|
+
dva_lab.exp1() # Shows PostgreSQL SQL queries and setup guide
|
|
210
|
+
dva_lab.exp3() # Plots vertical and horizontal bar charts
|
|
211
|
+
dva_lab.exp10() # Shows Power BI visual setup guide and previews dataset
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### `dva_lab.load_sales_data() -> pd.DataFrame`
|
|
215
|
+
Loads and returns the authoritative 10-record `sales_data.csv` used in Experiments 10โ12 as a pandas DataFrame:
|
|
216
|
+
```python
|
|
217
|
+
df = dva_lab.load_sales_data()
|
|
218
|
+
print(df.head())
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### `dva_lab.about()` / `dva_lab.help()`
|
|
222
|
+
Prints library version, repository information, and API guide.
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## ๐ฌ Experiment Execution Guidelines
|
|
227
|
+
|
|
228
|
+
### 1. SQL & OLAP Experiments (Experiments 1 and 2)
|
|
229
|
+
Experiments 1 and 2 define complete PostgreSQL scripts including DDL (`CREATE TABLE`), sample `INSERT` records, materialized views with `GROUP BY CUBE`, and OLAP queries (`Roll Up`, `Drill Down`, `Slice`, `Dice`, `Pivot`).
|
|
230
|
+
|
|
231
|
+
- **Safety Guarantee**: Calling `dva_lab.run_experiment(1)` or `dva_lab.exp1()` **never** executes SQL against an unconfigured server.
|
|
232
|
+
- **Live Execution**: If you have an active PostgreSQL connection (e.g. `psycopg2` or `SQLAlchemy`), pass it explicitly:
|
|
233
|
+
```python
|
|
234
|
+
dva_lab.run_experiment(1, connection=your_db_connection)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### 2. Python Plotting Experiments (Experiments 3 to 9)
|
|
238
|
+
All Python experiments run locally using Matplotlib, Seaborn, Statsmodels, and SciPy.
|
|
239
|
+
- Fully compatible with Jupyter `%matplotlib inline` backend.
|
|
240
|
+
- Deterministic synthetic data generated with `np.random.seed(0)`.
|
|
241
|
+
- Support individual sequential plots or combined views (`side_by_side=True`).
|
|
242
|
+
|
|
243
|
+
### 3. Power BI & DAX Experiments (Experiments 10 to 12)
|
|
244
|
+
Power BI Desktop reports are interactive Windows visual applications. `dva-lab` provides:
|
|
245
|
+
- Complete step-by-step instructions for fields, axes, and visual types.
|
|
246
|
+
- Exact DAX measures and calculated column formulas.
|
|
247
|
+
- Bundled CSV data via `dva_lab.load_sales_data()`.
|
|
248
|
+
- Built-in Python validation simulation reproducing the DAX calculations directly in pandas:
|
|
249
|
+
```python
|
|
250
|
+
from dva_lab.experiments.exp11_powerbi_dax import simulate_in_python
|
|
251
|
+
print(simulate_in_python())
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## ๐ Updating & Uninstalling
|
|
257
|
+
|
|
258
|
+
### Update to Latest Version
|
|
259
|
+
```python
|
|
260
|
+
%pip install --upgrade --force-reinstall git+https://github.com/AnandChowdari/dva-lab.git
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Uninstall
|
|
264
|
+
```python
|
|
265
|
+
%pip uninstall dva-lab -y
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## ๐งช Testing
|
|
271
|
+
|
|
272
|
+
The library comes with a complete test suite covering 100% of registry lookups, code snippets, headless plotting rendering, and DAX simulations:
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
pytest -v
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## ๐ค Contributing
|
|
281
|
+
|
|
282
|
+
1. Fork the repository on GitHub.
|
|
283
|
+
2. Clone your fork and create a feature branch (`git checkout -b feature/new-experiment`).
|
|
284
|
+
3. Add or update experiment files in `src/dva_lab/experiments/`.
|
|
285
|
+
4. Ensure all tests pass: `pytest`.
|
|
286
|
+
5. Submit a Pull Request.
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## ๐ License
|
|
291
|
+
|
|
292
|
+
This project is licensed under the [MIT License](LICENSE).
|
dva_lab-0.1.0/README.md
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# ๐ `dva-lab` โ Data Visualization & Analytics Laboratory Library
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://jupyter.org/)
|
|
6
|
+
[]()
|
|
7
|
+
|
|
8
|
+
**`dva-lab`** is an installable, self-contained Python library engineered for university students and educators. It enables students to retrieve, display, study, and execute all 12 Data Visualization and Analytics (DVA) laboratory experiments directly inside **Jupyter Notebook**, **JupyterLab**, or **Google Colab**.
|
|
9
|
+
|
|
10
|
+
The package stores the complete, authoritative source code, schemas, and datasets locally within the library. It does not depend on fetching code from the internet during runtime.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## ๐ Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Features](#-features)
|
|
17
|
+
- [Installation](#-installation)
|
|
18
|
+
- [Google Colab & Jupyter Notebook](#google-colab--jupyter-notebook)
|
|
19
|
+
- [Local Development & Pip](#local-development--pip)
|
|
20
|
+
- [Optional Dependency Sets](#optional-dependency-sets)
|
|
21
|
+
- [Quick Start](#-quick-start)
|
|
22
|
+
- [Complete Experiment Catalog](#-complete-experiment-catalog)
|
|
23
|
+
- [Public API Reference](#-public-api-reference)
|
|
24
|
+
- [Experiment Execution Guidelines](#-experiment-execution-guidelines)
|
|
25
|
+
- [SQL & OLAP Experiments (Exp 1 & 2)](#1-sql--olap-experiments-experiments-1-and-2)
|
|
26
|
+
- [Python Plotting Experiments (Exp 3 to 9)](#2-python-plotting-experiments-experiments-3-to-9)
|
|
27
|
+
- [Power BI & DAX Experiments (Exp 10 to 12)](#3-power-bi--dax-experiments-experiments-10-to-12)
|
|
28
|
+
- [Updating & Uninstalling](#-updating--uninstalling)
|
|
29
|
+
- [Contributing](#-contributing)
|
|
30
|
+
- [License](#-license)
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## ๐ Features
|
|
35
|
+
|
|
36
|
+
- **Jupyter-Native Experience**: Seamless inline rendering of Matplotlib/Seaborn plots and rich HTML/Markdown experiment guides.
|
|
37
|
+
- **Self-Contained & Deterministic**: Bundles all source code, SQL definitions, Power BI DAX expressions, and sample datasets (`sales_data.csv`).
|
|
38
|
+
- **Reproducible Seeds**: Synthetic distributions use fixed random seeds (`seed=0`) matching laboratory manual benchmarks.
|
|
39
|
+
- **Safe & Non-Destructive**: Never connects to an unknown database without explicit authorization and never attempts mock Power BI execution.
|
|
40
|
+
- **Convenient Shortcuts**: Direct function handles (`dva_lab.exp1()` through `dva_lab.exp12()`) for fast classroom access.
|
|
41
|
+
- **Lightweight Core**: Base install contains zero compulsory heavy dependencies with lazy imports for plotting engines.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## ๐ฆ Installation
|
|
46
|
+
|
|
47
|
+
### Google Colab & Jupyter Notebook
|
|
48
|
+
|
|
49
|
+
Paste and execute directly in a notebook cell:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
# Install directly from GitHub with visualization dependencies
|
|
53
|
+
%pip install "dva-lab[viz] @ git+https://github.com/AnandChowdari/dva-lab.git"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
*Note: Replace `AnandChowdari` with your GitHub username or organization repository URL.*
|
|
57
|
+
|
|
58
|
+
### Local Development & Pip
|
|
59
|
+
|
|
60
|
+
#### Windows (PowerShell):
|
|
61
|
+
```powershell
|
|
62
|
+
git clone https://github.com/AnandChowdari/dva-lab.git
|
|
63
|
+
cd dva-lab
|
|
64
|
+
pip install -e .[viz]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### macOS / Linux:
|
|
68
|
+
```bash
|
|
69
|
+
git clone https://github.com/AnandChowdari/dva-lab.git
|
|
70
|
+
cd dva-lab
|
|
71
|
+
pip install -e ".[viz]"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Optional Dependency Sets
|
|
75
|
+
|
|
76
|
+
| Group | Install Command | Included Packages | Purpose |
|
|
77
|
+
|---|---|---|---|
|
|
78
|
+
| **Base** | `pip install git+https://github.com/AnandChowdari/dva-lab.git` | Pure Python core | Code retrieval, schema inspection, CLI list |
|
|
79
|
+
| **`viz`** | `pip install "dva-lab[viz]"` | `matplotlib`, `numpy`, `seaborn`, `scipy`, `statsmodels` | Plotting experiments (Exp 3โ9) |
|
|
80
|
+
| **`full`** | `pip install "dva-lab[full]"` | `viz` + `pandas` + `ipython` | Full workbook with simulations & dataset tools |
|
|
81
|
+
| **`test`** | `pip install "dva-lab[test]"` | `viz` + `pandas` + `pytest` | Running the test suite locally |
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## โก Quick Start
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
import dva_lab
|
|
89
|
+
|
|
90
|
+
# 1. Discover all registered experiments
|
|
91
|
+
dva_lab.list_experiments()
|
|
92
|
+
|
|
93
|
+
# 2. Display formatted Markdown manual for Experiment 3
|
|
94
|
+
dva_lab.show_experiment(3)
|
|
95
|
+
|
|
96
|
+
# 3. Retrieve raw source code as a string
|
|
97
|
+
code = dva_lab.get_code(3)
|
|
98
|
+
print(code)
|
|
99
|
+
|
|
100
|
+
# 4. Execute experiment and render plots inline
|
|
101
|
+
dva_lab.exp3()
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## ๐ Complete Experiment Catalog
|
|
107
|
+
|
|
108
|
+
| # | Title | Category | Methodology / Tools | Focus |
|
|
109
|
+
|:---:|---|---|---|---|
|
|
110
|
+
| **1** | OLAP Operations Using Materialized Views | `OLAP & SQL` | PostgreSQL 12+, CUBE | Materialized view, Roll Up, Slice, Dice, Pivot |
|
|
111
|
+
| **2** | OLAP Operations Based on Star Schema | `OLAP & SQL` | PostgreSQL 12+, CUBE | Fact & dimension joins, Drill Down, Hierarchy |
|
|
112
|
+
| **3** | Vertical and Horizontal Bar Charts | `Python Visualization` | Matplotlib, NumPy | `plt.bar`, `plt.barh`, categorical comparison |
|
|
113
|
+
| **4** | Grouped and Stacked Bar Charts | `Python Visualization` | Matplotlib, NumPy | Positional offsets, stacked `bottom` vectors |
|
|
114
|
+
| **5** | Single & Multiple Variable Histograms | `Python Visualization` | Matplotlib, NumPy | Bin frequency, alpha transparency, normal distributions |
|
|
115
|
+
| **6** | Single & Multiple Variable Density Plots | `Python Visualization` | Seaborn, Matplotlib | Kernel Density Estimation (`sns.kdeplot`), area fills |
|
|
116
|
+
| **7** | Empirical Cumulative Distribution Function | `Python Visualization` | Statsmodels, Matplotlib | Non-parametric ECDF step function (`sm.distributions.ECDF`) |
|
|
117
|
+
| **8** | Q-Q Plot to Compare Datasets | `Python Visualization` | SciPy, Matplotlib | Normal probability quantiles (`stats.probplot`) |
|
|
118
|
+
| **9** | Scatter Plot Using Sample Data | `Python Visualization` | Matplotlib, NumPy | Bivariate scatter points, alpha blending, correlation |
|
|
119
|
+
| **10** | Power BI Sales Data Visualization | `Power BI` | Power BI Desktop, CSV | Column, Pie, Line, Card, Slicer dashboard |
|
|
120
|
+
| **11** | Power BI Calculations & DAX Measures | `Power BI` | DAX, Power BI Desktop | `Total Cost`, `Profit`, `CALCULATE`, `ALL`, percentages |
|
|
121
|
+
| **12** | Power BI Conditional & Logical Analysis | `Power BI` | DAX, Power BI Desktop | `IF`, `AND`, `OR`, `COUNTROWS`, dynamic sales tiers |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## ๐ Public API Reference
|
|
126
|
+
|
|
127
|
+
### `dva_lab.list_experiments()`
|
|
128
|
+
Returns a rich `ExperimentList` containing all 12 experiments.
|
|
129
|
+
- **In Jupyter**: Automatically renders a styled HTML table with badges.
|
|
130
|
+
- **In Terminal**: Displays an aligned text summary.
|
|
131
|
+
- **Convert to DataFrame**: `dva_lab.list_experiments().to_dataframe()`
|
|
132
|
+
|
|
133
|
+
### `dva_lab.show_experiment(number: int)`
|
|
134
|
+
Displays the complete laboratory manual for the experiment:
|
|
135
|
+
- Experiment Aim
|
|
136
|
+
- Theoretical Concept & Pedagogical Context
|
|
137
|
+
- Complete, Corrected Input Code
|
|
138
|
+
- Expected Visual Output or Result Table
|
|
139
|
+
- Result Statement
|
|
140
|
+
- Execution Notes & Errata
|
|
141
|
+
|
|
142
|
+
### `dva_lab.get_code(number: int) -> str`
|
|
143
|
+
Returns the exact, clean source code string for inspection or programmatic export:
|
|
144
|
+
```python
|
|
145
|
+
with open("exp03.py", "w") as f:
|
|
146
|
+
f.write(dva_lab.get_code(3))
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### `dva_lab.run_experiment(number: int, **kwargs)`
|
|
150
|
+
Executes the specified experiment:
|
|
151
|
+
- For Python experiments (3โ9): Renders plots inline.
|
|
152
|
+
- Optional arguments:
|
|
153
|
+
- `show=True`: Call `plt.show()` inline.
|
|
154
|
+
- `side_by_side=True`: For multi-plot experiments (3, 4, 5, 6), combines subplots horizontally.
|
|
155
|
+
|
|
156
|
+
### Convenience Shortcuts (`dva_lab.exp1()` ... `dva_lab.exp12()`)
|
|
157
|
+
One-line helper functions to immediately access any experiment:
|
|
158
|
+
```python
|
|
159
|
+
dva_lab.exp1() # Shows PostgreSQL SQL queries and setup guide
|
|
160
|
+
dva_lab.exp3() # Plots vertical and horizontal bar charts
|
|
161
|
+
dva_lab.exp10() # Shows Power BI visual setup guide and previews dataset
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### `dva_lab.load_sales_data() -> pd.DataFrame`
|
|
165
|
+
Loads and returns the authoritative 10-record `sales_data.csv` used in Experiments 10โ12 as a pandas DataFrame:
|
|
166
|
+
```python
|
|
167
|
+
df = dva_lab.load_sales_data()
|
|
168
|
+
print(df.head())
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### `dva_lab.about()` / `dva_lab.help()`
|
|
172
|
+
Prints library version, repository information, and API guide.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## ๐ฌ Experiment Execution Guidelines
|
|
177
|
+
|
|
178
|
+
### 1. SQL & OLAP Experiments (Experiments 1 and 2)
|
|
179
|
+
Experiments 1 and 2 define complete PostgreSQL scripts including DDL (`CREATE TABLE`), sample `INSERT` records, materialized views with `GROUP BY CUBE`, and OLAP queries (`Roll Up`, `Drill Down`, `Slice`, `Dice`, `Pivot`).
|
|
180
|
+
|
|
181
|
+
- **Safety Guarantee**: Calling `dva_lab.run_experiment(1)` or `dva_lab.exp1()` **never** executes SQL against an unconfigured server.
|
|
182
|
+
- **Live Execution**: If you have an active PostgreSQL connection (e.g. `psycopg2` or `SQLAlchemy`), pass it explicitly:
|
|
183
|
+
```python
|
|
184
|
+
dva_lab.run_experiment(1, connection=your_db_connection)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 2. Python Plotting Experiments (Experiments 3 to 9)
|
|
188
|
+
All Python experiments run locally using Matplotlib, Seaborn, Statsmodels, and SciPy.
|
|
189
|
+
- Fully compatible with Jupyter `%matplotlib inline` backend.
|
|
190
|
+
- Deterministic synthetic data generated with `np.random.seed(0)`.
|
|
191
|
+
- Support individual sequential plots or combined views (`side_by_side=True`).
|
|
192
|
+
|
|
193
|
+
### 3. Power BI & DAX Experiments (Experiments 10 to 12)
|
|
194
|
+
Power BI Desktop reports are interactive Windows visual applications. `dva-lab` provides:
|
|
195
|
+
- Complete step-by-step instructions for fields, axes, and visual types.
|
|
196
|
+
- Exact DAX measures and calculated column formulas.
|
|
197
|
+
- Bundled CSV data via `dva_lab.load_sales_data()`.
|
|
198
|
+
- Built-in Python validation simulation reproducing the DAX calculations directly in pandas:
|
|
199
|
+
```python
|
|
200
|
+
from dva_lab.experiments.exp11_powerbi_dax import simulate_in_python
|
|
201
|
+
print(simulate_in_python())
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## ๐ Updating & Uninstalling
|
|
207
|
+
|
|
208
|
+
### Update to Latest Version
|
|
209
|
+
```python
|
|
210
|
+
%pip install --upgrade --force-reinstall git+https://github.com/AnandChowdari/dva-lab.git
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Uninstall
|
|
214
|
+
```python
|
|
215
|
+
%pip uninstall dva-lab -y
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## ๐งช Testing
|
|
221
|
+
|
|
222
|
+
The library comes with a complete test suite covering 100% of registry lookups, code snippets, headless plotting rendering, and DAX simulations:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
pytest -v
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## ๐ค Contributing
|
|
231
|
+
|
|
232
|
+
1. Fork the repository on GitHub.
|
|
233
|
+
2. Clone your fork and create a feature branch (`git checkout -b feature/new-experiment`).
|
|
234
|
+
3. Add or update experiment files in `src/dva_lab/experiments/`.
|
|
235
|
+
4. Ensure all tests pass: `pytest`.
|
|
236
|
+
5. Submit a Pull Request.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## ๐ License
|
|
241
|
+
|
|
242
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "dva-lab"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A Python package for Data Visualization and Analytics (DVA) laboratory experiments in Jupyter Notebook."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "DVA Lab Team", email = "dva-lab@example.com" }
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"data-visualization",
|
|
17
|
+
"analytics",
|
|
18
|
+
"dva",
|
|
19
|
+
"jupyter",
|
|
20
|
+
"matplotlib",
|
|
21
|
+
"seaborn",
|
|
22
|
+
"powerbi",
|
|
23
|
+
"olap",
|
|
24
|
+
"sql",
|
|
25
|
+
]
|
|
26
|
+
classifiers = [
|
|
27
|
+
"Development Status :: 4 - Beta",
|
|
28
|
+
"Intended Audience :: Education",
|
|
29
|
+
"Intended Audience :: Science/Research",
|
|
30
|
+
"License :: OSI Approved :: MIT License",
|
|
31
|
+
"Programming Language :: Python :: 3",
|
|
32
|
+
"Programming Language :: Python :: 3.10",
|
|
33
|
+
"Programming Language :: Python :: 3.11",
|
|
34
|
+
"Programming Language :: Python :: 3.12",
|
|
35
|
+
"Programming Language :: Python :: 3.13",
|
|
36
|
+
"Topic :: Scientific/Engineering :: Visualization",
|
|
37
|
+
"Framework :: Jupyter",
|
|
38
|
+
]
|
|
39
|
+
dependencies = [
|
|
40
|
+
"matplotlib>=3.5.0",
|
|
41
|
+
"numpy>=1.20.0",
|
|
42
|
+
"seaborn>=0.12.0",
|
|
43
|
+
"scipy>=1.7.0",
|
|
44
|
+
"statsmodels>=0.13.0",
|
|
45
|
+
"pandas>=1.3.0",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.optional-dependencies]
|
|
49
|
+
viz = [
|
|
50
|
+
"matplotlib>=3.5.0",
|
|
51
|
+
"numpy>=1.20.0",
|
|
52
|
+
"seaborn>=0.12.0",
|
|
53
|
+
"scipy>=1.7.0",
|
|
54
|
+
"statsmodels>=0.13.0",
|
|
55
|
+
]
|
|
56
|
+
full = [
|
|
57
|
+
"dva-lab[viz]",
|
|
58
|
+
"pandas>=1.3.0",
|
|
59
|
+
"ipython>=8.0.0",
|
|
60
|
+
]
|
|
61
|
+
test = [
|
|
62
|
+
"pytest>=7.0.0",
|
|
63
|
+
"matplotlib>=3.5.0",
|
|
64
|
+
"numpy>=1.20.0",
|
|
65
|
+
"seaborn>=0.12.0",
|
|
66
|
+
"scipy>=1.7.0",
|
|
67
|
+
"statsmodels>=0.13.0",
|
|
68
|
+
"pandas>=1.3.0",
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
[project.urls]
|
|
72
|
+
Homepage = "https://github.com/AnandChowdari/dva-lab"
|
|
73
|
+
Repository = "https://github.com/AnandChowdari/dva-lab.git"
|
|
74
|
+
Issues = "https://github.com/AnandChowdari/dva-lab/issues"
|
|
75
|
+
|
|
76
|
+
[tool.setuptools.packages.find]
|
|
77
|
+
where = ["src"]
|
|
78
|
+
|
|
79
|
+
[tool.setuptools.package-data]
|
|
80
|
+
"dva_lab" = ["data/*.csv"]
|
|
81
|
+
|
|
82
|
+
[tool.pytest.ini_options]
|
|
83
|
+
testpaths = ["tests"]
|
|
84
|
+
python_files = ["test_*.py"]
|
|
85
|
+
python_functions = ["test_*"]
|
|
86
|
+
filterwarnings = [
|
|
87
|
+
"ignore::DeprecationWarning",
|
|
88
|
+
"ignore::UserWarning",
|
|
89
|
+
]
|
dva_lab-0.1.0/setup.cfg
ADDED