pandalens 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.
- pandalens-0.1.0/LICENSE +21 -0
- pandalens-0.1.0/PKG-INFO +70 -0
- pandalens-0.1.0/README.md +47 -0
- pandalens-0.1.0/pandalens/__init__.py +70 -0
- pandalens-0.1.0/pandalens/_auto.py +472 -0
- pandalens-0.1.0/pandalens/_core.py +201 -0
- pandalens-0.1.0/pandalens/_hooks.py +628 -0
- pandalens-0.1.0/pandalens/_page.html +127 -0
- pandalens-0.1.0/pandalens/_render.py +156 -0
- pandalens-0.1.0/pandalens/_server.py +119 -0
- pandalens-0.1.0/pandalens.egg-info/PKG-INFO +70 -0
- pandalens-0.1.0/pandalens.egg-info/SOURCES.txt +15 -0
- pandalens-0.1.0/pandalens.egg-info/dependency_links.txt +1 -0
- pandalens-0.1.0/pandalens.egg-info/requires.txt +2 -0
- pandalens-0.1.0/pandalens.egg-info/top_level.txt +1 -0
- pandalens-0.1.0/pyproject.toml +35 -0
- pandalens-0.1.0/setup.cfg +4 -0
pandalens-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Eric Nelson
|
|
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.
|
pandalens-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pandalens
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: See what pandas does to your data, step by step, in a live browser tab. A teaching aid for beginners.
|
|
5
|
+
Author: Eric Nelson
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: pandas,education,visualization,debugging,teaching
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Education
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Topic :: Education
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: pandas>=2.2
|
|
21
|
+
Requires-Dist: numpy
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# pandalens
|
|
25
|
+
|
|
26
|
+
Watch what pandas does to your data, one step at a time.
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
import pandalens # opens a live view in your browser
|
|
30
|
+
import pandas as pd
|
|
31
|
+
|
|
32
|
+
df = pd.DataFrame({"k": [1, 1, 2], "x": [1.0, 2.0, 3.0]})
|
|
33
|
+
med = df.groupby("k")["x"].median() # the browser shows the groups, colored
|
|
34
|
+
med = med.reset_index() # ...and why the index became a column
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Every pandas call you make (`merge`, `groupby`, `reset_index`, filtering, new columns, ...) appears as a step in
|
|
38
|
+
the browser tab, with before/after tables, colors showing which rows went where, and a plain-English explanation.
|
|
39
|
+
Use the step log on the left to review earlier steps, and the variables panel on the right to keep any
|
|
40
|
+
DataFrame or Series in view.
|
|
41
|
+
|
|
42
|
+
It works with breakpoints: the browser tab runs in its own process, so it keeps working while your program is paused.
|
|
43
|
+
|
|
44
|
+
## What is shown
|
|
45
|
+
|
|
46
|
+
Nearly everything you can call in pandas is recorded: creating DataFrames, `df['a']`, `df[mask]`, `.loc`/`.iloc`,
|
|
47
|
+
operators like `a + b` and `x > 0`, `merge`/`concat`/`join`, `groupby` (rows colored by group), `reset_index`,
|
|
48
|
+
`sort_values`, `fillna`, `rolling`, `.str`/`.dt` methods, `pivot_table`, `read_csv`, and hundreds more. Each step shows the
|
|
49
|
+
data before and after, highlights what changed, and explains it (in plain English for the common operations, and with
|
|
50
|
+
pandas' own one-line description for the rest).
|
|
51
|
+
|
|
52
|
+
## Controls
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
pandalens.pause(); pandalens.resume()
|
|
56
|
+
with pandalens.group("my step"): # show several calls as one entry
|
|
57
|
+
...
|
|
58
|
+
pandalens.show(df, "my table") # snapshot any DataFrame
|
|
59
|
+
pandalens.clear()
|
|
60
|
+
pandalens.stop()
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Set `PANDALENS_NO_BROWSER=1` to stop the browser from opening automatically (the address is printed instead).
|
|
64
|
+
|
|
65
|
+
## Requirements
|
|
66
|
+
|
|
67
|
+
Python 3.10+ and pandas 2.2 or newer.
|
|
68
|
+
Tested with pandas 2.3 and 3.1 on Python 3.12.
|
|
69
|
+
|
|
70
|
+
Status: early alpha, built as a teaching aid.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# pandalens
|
|
2
|
+
|
|
3
|
+
Watch what pandas does to your data, one step at a time.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
import pandalens # opens a live view in your browser
|
|
7
|
+
import pandas as pd
|
|
8
|
+
|
|
9
|
+
df = pd.DataFrame({"k": [1, 1, 2], "x": [1.0, 2.0, 3.0]})
|
|
10
|
+
med = df.groupby("k")["x"].median() # the browser shows the groups, colored
|
|
11
|
+
med = med.reset_index() # ...and why the index became a column
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Every pandas call you make (`merge`, `groupby`, `reset_index`, filtering, new columns, ...) appears as a step in
|
|
15
|
+
the browser tab, with before/after tables, colors showing which rows went where, and a plain-English explanation.
|
|
16
|
+
Use the step log on the left to review earlier steps, and the variables panel on the right to keep any
|
|
17
|
+
DataFrame or Series in view.
|
|
18
|
+
|
|
19
|
+
It works with breakpoints: the browser tab runs in its own process, so it keeps working while your program is paused.
|
|
20
|
+
|
|
21
|
+
## What is shown
|
|
22
|
+
|
|
23
|
+
Nearly everything you can call in pandas is recorded: creating DataFrames, `df['a']`, `df[mask]`, `.loc`/`.iloc`,
|
|
24
|
+
operators like `a + b` and `x > 0`, `merge`/`concat`/`join`, `groupby` (rows colored by group), `reset_index`,
|
|
25
|
+
`sort_values`, `fillna`, `rolling`, `.str`/`.dt` methods, `pivot_table`, `read_csv`, and hundreds more. Each step shows the
|
|
26
|
+
data before and after, highlights what changed, and explains it (in plain English for the common operations, and with
|
|
27
|
+
pandas' own one-line description for the rest).
|
|
28
|
+
|
|
29
|
+
## Controls
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
pandalens.pause(); pandalens.resume()
|
|
33
|
+
with pandalens.group("my step"): # show several calls as one entry
|
|
34
|
+
...
|
|
35
|
+
pandalens.show(df, "my table") # snapshot any DataFrame
|
|
36
|
+
pandalens.clear()
|
|
37
|
+
pandalens.stop()
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Set `PANDALENS_NO_BROWSER=1` to stop the browser from opening automatically (the address is printed instead).
|
|
41
|
+
|
|
42
|
+
## Requirements
|
|
43
|
+
|
|
44
|
+
Python 3.10+ and pandas 2.2 or newer.
|
|
45
|
+
Tested with pandas 2.3 and 3.1 on Python 3.12.
|
|
46
|
+
|
|
47
|
+
Status: early alpha, built as a teaching aid.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""pandalens: watch what pandas does to your data, step by step, in a live browser tab.
|
|
2
|
+
|
|
3
|
+
import pandalens # starts watching immediately (opens the tab)
|
|
4
|
+
|
|
5
|
+
pandalens.pause() / pandalens.resume()
|
|
6
|
+
with pandalens.group("monthly weights"): # several steps shown as ONE entry
|
|
7
|
+
...
|
|
8
|
+
pandalens.show(df, "my table") # snapshot any dataframe
|
|
9
|
+
pandalens.clear() # empty the tab
|
|
10
|
+
pandalens.stop() # unpatch pandas and shut the tab's server down
|
|
11
|
+
"""
|
|
12
|
+
import contextlib
|
|
13
|
+
import os
|
|
14
|
+
|
|
15
|
+
from . import _core, _hooks, _render as R
|
|
16
|
+
|
|
17
|
+
__all__ = ["watch", "stop", "pause", "resume", "clear", "group", "show"]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def watch(open_browser=True, console=True):
|
|
21
|
+
"""Start watching (called automatically on import). console=False silences the one-line console summaries."""
|
|
22
|
+
_core.S.console = console
|
|
23
|
+
_hooks.install()
|
|
24
|
+
if _core.S.port is None:
|
|
25
|
+
_core.start_server(open_browser)
|
|
26
|
+
_core.S.enabled = True
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def stop():
|
|
30
|
+
_core.S.enabled = False
|
|
31
|
+
_hooks.uninstall()
|
|
32
|
+
_core.stop_server()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def pause():
|
|
36
|
+
_core.S.enabled = False
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def resume():
|
|
40
|
+
_core.S.recent.clear()
|
|
41
|
+
_core.S.enabled = True
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def clear():
|
|
45
|
+
_core.clear()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@contextlib.contextmanager
|
|
49
|
+
def group(name):
|
|
50
|
+
"""Collapse everything that happens inside the block into one entry."""
|
|
51
|
+
children = []
|
|
52
|
+
_core.S.groups.append(children)
|
|
53
|
+
try:
|
|
54
|
+
yield
|
|
55
|
+
finally:
|
|
56
|
+
_core.S.groups.pop()
|
|
57
|
+
if _core.S.groups:
|
|
58
|
+
_core.S.groups[-1].extend(children)
|
|
59
|
+
elif children:
|
|
60
|
+
_core.emit_group(name, children)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def show(df, title="snapshot"):
|
|
64
|
+
"""Put a snapshot of a DataFrame/Series in the tab."""
|
|
65
|
+
html = R.card(title, f"show({title!r})", R.dims(df), [R.section("data", R.table(df))])
|
|
66
|
+
_core.emit_event({"title": title, "call": f"show({title!r})", "assigned": None, "html": html},
|
|
67
|
+
{title: df}, f"show: {title} ({R.dims(df)})")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
watch(open_browser=not os.environ.get("PANDALENS_NO_BROWSER"))
|