df-eval 0.1.1__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.
- df_eval-0.1.1/.github/workflows/ci.yml +80 -0
- df_eval-0.1.1/.github/workflows/docs.yml +48 -0
- df_eval-0.1.1/.github/workflows/publish_to_pypi.yml +44 -0
- df_eval-0.1.1/.gitignore +208 -0
- df_eval-0.1.1/CONTRIBUTING.md +34 -0
- df_eval-0.1.1/LICENSE +21 -0
- df_eval-0.1.1/PKG-INFO +206 -0
- df_eval-0.1.1/README.md +166 -0
- df_eval-0.1.1/assets/icon/df-eval-icon-dark.svg +42 -0
- df_eval-0.1.1/assets/icon/df-eval-icon-light.svg +55 -0
- df_eval-0.1.1/assets/icon/df-eval-icon.svg +84 -0
- df_eval-0.1.1/docs/_static/.gitkeep +0 -0
- df_eval-0.1.1/docs/_static/branding/df-eval-icon-dark.svg +42 -0
- df_eval-0.1.1/docs/_static/branding/df-eval-icon-light.svg +55 -0
- df_eval-0.1.1/docs/_static/branding/df-eval-icon.svg +84 -0
- df_eval-0.1.1/docs/conf.py +96 -0
- df_eval-0.1.1/docs/examples/README.txt +10 -0
- df_eval-0.1.1/docs/examples/basic_engine_usage.py +88 -0
- df_eval-0.1.1/docs/examples/error_handling_and_debugging.py +90 -0
- df_eval-0.1.1/docs/examples/lookup_engine_integration.py +107 -0
- df_eval-0.1.1/docs/examples/lookup_pandera_pipeline.py +131 -0
- df_eval-0.1.1/docs/examples/pandera_integration.py +98 -0
- df_eval-0.1.1/docs/examples/parquet_out_of_memory.py +111 -0
- df_eval-0.1.1/docs/examples/performance_and_scalability.py +61 -0
- df_eval-0.1.1/docs/index.rst +19 -0
- df_eval-0.1.1/docs/reference/api.rst +59 -0
- df_eval-0.1.1/docs/user_guide/advanced_usage.rst +368 -0
- df_eval-0.1.1/docs/user_guide/basic_usage.rst +217 -0
- df_eval-0.1.1/docs/user_guide/index.rst +75 -0
- df_eval-0.1.1/docs/user_guide/lookups.rst +437 -0
- df_eval-0.1.1/pyproject.toml +88 -0
- df_eval-0.1.1/src/df_eval/__init__.py +53 -0
- df_eval-0.1.1/src/df_eval/engine.py +611 -0
- df_eval-0.1.1/src/df_eval/expr.py +91 -0
- df_eval-0.1.1/src/df_eval/functions.py +124 -0
- df_eval-0.1.1/src/df_eval/lookup.py +210 -0
- df_eval-0.1.1/src/df_eval/pandera.py +452 -0
- df_eval-0.1.1/src/df_eval/parquet.py +166 -0
- df_eval-0.1.1/src/df_eval/utils/__init__.py +0 -0
- df_eval-0.1.1/src/df_eval/utils/pandera_io_compat.py +849 -0
- df_eval-0.1.1/tests/test_engine.py +83 -0
- df_eval-0.1.1/tests/test_engine_enhanced.py +133 -0
- df_eval-0.1.1/tests/test_engine_lookups.py +9 -0
- df_eval-0.1.1/tests/test_engine_parquet.py +137 -0
- df_eval-0.1.1/tests/test_expr.py +28 -0
- df_eval-0.1.1/tests/test_expr_enhanced.py +53 -0
- df_eval-0.1.1/tests/test_functions.py +86 -0
- df_eval-0.1.1/tests/test_lookup.py +131 -0
- df_eval-0.1.1/tests/test_pandera.py +430 -0
- df_eval-0.1.1/tests/test_parquet.py +88 -0
- df_eval-0.1.1/tests/test_safe_functions.py +86 -0
- df_eval-0.1.1/uv.lock +2320 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
matrix:
|
|
17
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Install uv
|
|
23
|
+
uses: astral-sh/setup-uv@v5
|
|
24
|
+
with:
|
|
25
|
+
enable-cache: true
|
|
26
|
+
|
|
27
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
28
|
+
uses: actions/setup-python@v5
|
|
29
|
+
with:
|
|
30
|
+
python-version: ${{ matrix.python-version }}
|
|
31
|
+
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: |
|
|
34
|
+
uv sync --all-extras
|
|
35
|
+
|
|
36
|
+
- name: Run tests
|
|
37
|
+
run: |
|
|
38
|
+
uv run pytest --cov=df_eval --cov-report=xml --cov-report=term
|
|
39
|
+
|
|
40
|
+
- name: Upload coverage to Codecov
|
|
41
|
+
uses: codecov/codecov-action@v4
|
|
42
|
+
if: matrix.python-version == '3.11'
|
|
43
|
+
with:
|
|
44
|
+
file: ./coverage.xml
|
|
45
|
+
flags: unittests
|
|
46
|
+
name: codecov-umbrella
|
|
47
|
+
fail_ci_if_error: false
|
|
48
|
+
|
|
49
|
+
docs:
|
|
50
|
+
runs-on: ubuntu-latest
|
|
51
|
+
permissions:
|
|
52
|
+
contents: read
|
|
53
|
+
|
|
54
|
+
steps:
|
|
55
|
+
- uses: actions/checkout@v4
|
|
56
|
+
|
|
57
|
+
- name: Install uv
|
|
58
|
+
uses: astral-sh/setup-uv@v5
|
|
59
|
+
with:
|
|
60
|
+
enable-cache: true
|
|
61
|
+
|
|
62
|
+
- name: Set up Python
|
|
63
|
+
uses: actions/setup-python@v5
|
|
64
|
+
with:
|
|
65
|
+
python-version: "3.11"
|
|
66
|
+
|
|
67
|
+
- name: Install dependencies
|
|
68
|
+
run: |
|
|
69
|
+
uv sync --all-extras
|
|
70
|
+
|
|
71
|
+
- name: Build documentation
|
|
72
|
+
run: |
|
|
73
|
+
cd docs
|
|
74
|
+
uv run sphinx-build -b html . _build/html -W
|
|
75
|
+
|
|
76
|
+
- name: Upload documentation artifacts
|
|
77
|
+
uses: actions/upload-artifact@v4
|
|
78
|
+
with:
|
|
79
|
+
name: documentation
|
|
80
|
+
path: docs/_build/html
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
pages: write
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up Python
|
|
20
|
+
uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: "3.11"
|
|
23
|
+
|
|
24
|
+
- name: Install uv
|
|
25
|
+
uses: astral-sh/setup-uv@v5
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: uv sync --extra dev
|
|
29
|
+
|
|
30
|
+
- name: Build Sphinx HTML
|
|
31
|
+
run: |
|
|
32
|
+
uv run sphinx-build -b html docs docs/_build/html
|
|
33
|
+
|
|
34
|
+
- name: Upload Pages artifact
|
|
35
|
+
uses: actions/upload-pages-artifact@v3
|
|
36
|
+
with:
|
|
37
|
+
path: docs/_build/html
|
|
38
|
+
|
|
39
|
+
deploy:
|
|
40
|
+
needs: build
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
environment:
|
|
43
|
+
name: github-pages
|
|
44
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
45
|
+
steps:
|
|
46
|
+
- name: Deploy to GitHub Pages
|
|
47
|
+
id: deployment
|
|
48
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
name: Publish to PyPI
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
release:
|
|
6
|
+
types: [published]
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
publish:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
permissions:
|
|
13
|
+
id-token: write
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout code
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Set up Python
|
|
21
|
+
uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: "3.12"
|
|
24
|
+
|
|
25
|
+
- name: Install uv
|
|
26
|
+
run: pip install uv
|
|
27
|
+
|
|
28
|
+
# ✅ Sync dependencies from uv.lock
|
|
29
|
+
- name: Sync dependencies
|
|
30
|
+
run: uv sync --frozen
|
|
31
|
+
|
|
32
|
+
# ✅ Install packaging tools
|
|
33
|
+
- name: Install build tools
|
|
34
|
+
run: uv pip install build twine
|
|
35
|
+
|
|
36
|
+
# ✅ Build the package
|
|
37
|
+
- name: Build package
|
|
38
|
+
run: uv run python -m build
|
|
39
|
+
|
|
40
|
+
# ✅ Publish to PyPI using Trusted Publisher
|
|
41
|
+
- name: Publish to PyPI
|
|
42
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
43
|
+
with:
|
|
44
|
+
skip-existing: true
|
df_eval-0.1.1/.gitignore
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
208
|
+
/docs/auto_examples/
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
# Documentation Policy
|
|
3
|
+
|
|
4
|
+
## README.md
|
|
5
|
+
- The root `README.md` is the **only Markdown file** in the project.
|
|
6
|
+
- It serves as the landing page for **GitHub** and **PyPI** and may be included in Sphinx as the index page.
|
|
7
|
+
|
|
8
|
+
## Sphinx Documentation
|
|
9
|
+
- All documentation under `docs/` **must use reStructuredText (`.rst`)** format.
|
|
10
|
+
- Markdown files are **not allowed** in `docs/` except for the root `README.md`.
|
|
11
|
+
- Use Sphinx directives and roles for cross-referencing and advanced features.
|
|
12
|
+
|
|
13
|
+
## Heading Style for `.rst`
|
|
14
|
+
- One **double underline heading** at the top of the page (Level 1).
|
|
15
|
+
- Subsequent headings use **single underline** (Level 2) or `^` for Level 3 as needed.
|
|
16
|
+
- Example:
|
|
17
|
+
```rst
|
|
18
|
+
Main Title
|
|
19
|
+
==========
|
|
20
|
+
|
|
21
|
+
Section
|
|
22
|
+
--------
|
|
23
|
+
|
|
24
|
+
Subsection
|
|
25
|
+
^^^^^^^^^^
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Tools & Standards
|
|
29
|
+
- Use **Google-style docstrings** in Python code.
|
|
30
|
+
- Use `pathlib.Path` for file paths.
|
|
31
|
+
- Follow best practices for Python programming:
|
|
32
|
+
- Object-Oriented Programming (OOP) where appropriate.
|
|
33
|
+
- Sphinx for documentation with `.rst` files.
|
|
34
|
+
``
|
df_eval-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Greg Elphick
|
|
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.
|
df_eval-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: df-eval
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: A lightweight expression evaluation engine for pandas DataFrames
|
|
5
|
+
Author: Greg Elphick
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Requires-Dist: pandas>=2.0.0
|
|
17
|
+
Provides-Extra: all
|
|
18
|
+
Requires-Dist: black>=23.0.0; extra == 'all'
|
|
19
|
+
Requires-Dist: frictionless>=4.0.0; extra == 'all'
|
|
20
|
+
Requires-Dist: pandera[io]>=0.20.0; extra == 'all'
|
|
21
|
+
Requires-Dist: pyarrow>=15.0.0; extra == 'all'
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: matplotlib>=3.8.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: myst-parser>=2.0.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: pandera>=0.20.0; extra == 'dev'
|
|
26
|
+
Requires-Dist: pyarrow>=15.0.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: sphinx-autodoc-typehints>=1.24.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: sphinx-book-theme>=1.0.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: sphinx-gallery>=0.16.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: sphinx>=7.0.0; extra == 'dev'
|
|
33
|
+
Provides-Extra: pandera
|
|
34
|
+
Requires-Dist: black>=23.0.0; extra == 'pandera'
|
|
35
|
+
Requires-Dist: frictionless>=4.0.0; extra == 'pandera'
|
|
36
|
+
Requires-Dist: pandera[io]>=0.20.0; extra == 'pandera'
|
|
37
|
+
Provides-Extra: parquet
|
|
38
|
+
Requires-Dist: pyarrow>=15.0.0; extra == 'parquet'
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
|
|
41
|
+
# df-eval
|
|
42
|
+
|
|
43
|
+
<p align="center">
|
|
44
|
+
<img src="https://raw.githubusercontent.com/elphick/df-eval/main/docs/_static/branding/df-eval-icon.svg" alt="df-eval icon" width="120" />
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
[](https://github.com/elphick/df-eval/actions/workflows/ci.yml)
|
|
48
|
+
[](https://github.com/elphick/df-eval/actions/workflows/docs.yml)
|
|
49
|
+
[](https://www.python.org/downloads/)
|
|
50
|
+
[](https://opensource.org/licenses/MIT)
|
|
51
|
+
[](https://github.com/psf/black)
|
|
52
|
+
|
|
53
|
+
A lightweight expression evaluation engine for pandas DataFrames, supporting schema-driven derived columns and external lookups.
|
|
54
|
+
|
|
55
|
+
## Overview
|
|
56
|
+
|
|
57
|
+
**df-eval** is a Python library that provides a flexible and efficient way to evaluate expressions on pandas DataFrames. It's designed for scenarios where you need to:
|
|
58
|
+
|
|
59
|
+
- Apply complex transformations to DataFrames using string expressions
|
|
60
|
+
- Define schemas of derived columns that depend on existing columns
|
|
61
|
+
- Register custom functions (UDFs) and constants for use in expressions
|
|
62
|
+
- Use safe, allow-listed functions (abs, log, exp, sqrt, clip, where, isna, fillna)
|
|
63
|
+
- Handle dependencies between derived columns with automatic topological ordering
|
|
64
|
+
- Perform lookups from external data sources (files, databases, HTTP APIs)
|
|
65
|
+
- Track provenance of derived columns
|
|
66
|
+
- Maintain clean, readable code for data transformations
|
|
67
|
+
|
|
68
|
+
## Features
|
|
69
|
+
|
|
70
|
+
- **Safe Expression Evaluation**: Allow-listed vectorized functions for secure evaluation
|
|
71
|
+
- **UDF and Constant Registry**: Register custom functions and constants
|
|
72
|
+
- **Schema-Driven Columns**: Define multiple derived columns with automatic dependency resolution
|
|
73
|
+
- **Topological Ordering**: Automatically resolve dependencies between columns
|
|
74
|
+
- **Cycle Detection**: Detect and report circular dependencies
|
|
75
|
+
- **Dtype Casting**: Specify output types for derived columns
|
|
76
|
+
- **Provenance Tracking**: Track the origin and dependencies of derived columns
|
|
77
|
+
- **Lookup Functionality**: Resolve values from external sources with caching
|
|
78
|
+
- **Type-Safe**: Built with Python 3.11+ type hints
|
|
79
|
+
- **Well-Tested**: Comprehensive test suite with 95%+ coverage
|
|
80
|
+
- **Well-Documented**: Full documentation with Sphinx
|
|
81
|
+
- **Backend Seam**: Designed for future Arrow/Polars support
|
|
82
|
+
|
|
83
|
+
## Installation
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install df-eval
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For development:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
git clone https://github.com/elphick/df-eval.git
|
|
93
|
+
cd df-eval
|
|
94
|
+
uv sync
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Quick Start
|
|
98
|
+
|
|
99
|
+
### Basic Expression Evaluation
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
import pandas as pd
|
|
103
|
+
from df_eval import Engine
|
|
104
|
+
|
|
105
|
+
# Create a DataFrame
|
|
106
|
+
df = pd.DataFrame({
|
|
107
|
+
"a": [1, 2, 3],
|
|
108
|
+
"b": [4, 5, 6]
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
# Create an engine
|
|
112
|
+
engine = Engine()
|
|
113
|
+
|
|
114
|
+
# Evaluate an expression
|
|
115
|
+
result = engine.evaluate(df, "a + b")
|
|
116
|
+
print(result) # [5, 7, 9]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Schema-Driven Derived Columns
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
# Define a schema with dependent columns
|
|
123
|
+
schema = {
|
|
124
|
+
"sum": "a + b",
|
|
125
|
+
"product": "a * b",
|
|
126
|
+
"ratio": "a / b"
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
df_with_derived = engine.apply_schema(df, schema)
|
|
130
|
+
print(df_with_derived)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Using Allow-Listed Safe Functions
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
# Use safe, allow-listed functions
|
|
137
|
+
schema = {
|
|
138
|
+
"abs_a": "abs(a)",
|
|
139
|
+
"log_b": "log(b)",
|
|
140
|
+
"sqrt_sum": "sqrt(a + b)",
|
|
141
|
+
"clipped": "clip(a, 0, 2)"
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
result = engine.apply_schema(df, schema)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Register Custom Functions (UDFs)
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
# Register a custom function
|
|
151
|
+
def custom_transform(x):
|
|
152
|
+
return x ** 2 + 10
|
|
153
|
+
|
|
154
|
+
engine.register_function("transform", custom_transform)
|
|
155
|
+
|
|
156
|
+
# Use it in expressions
|
|
157
|
+
result = engine.evaluate(df, "transform(a)")
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Built-in Functions
|
|
161
|
+
|
|
162
|
+
The library provides several allow-listed safe functions:
|
|
163
|
+
|
|
164
|
+
- `abs(x)`: Absolute value
|
|
165
|
+
- `log(x)`: Natural logarithm (handles negative values safely)
|
|
166
|
+
- `exp(x)`: Exponential function (handles overflow safely)
|
|
167
|
+
- `sqrt(x)`: Square root (handles negative values safely)
|
|
168
|
+
- `clip(x, min, max)`: Clip values to a range
|
|
169
|
+
- `where(condition, x, y)`: Conditional selection
|
|
170
|
+
- `isna(x)`: Check for NaN/None values
|
|
171
|
+
- `fillna(x, value)`: Fill NaN/None with a value
|
|
172
|
+
- `safe_divide(a, b)`: Division with NaN for divide-by-zero
|
|
173
|
+
- `coalesce(*args)`: Return first non-null value
|
|
174
|
+
|
|
175
|
+
## Documentation
|
|
176
|
+
|
|
177
|
+
For comprehensive documentation including advanced usage, API reference, and more examples, visit the [full documentation](https://elphick.github.io/df-eval/).
|
|
178
|
+
|
|
179
|
+
## Requirements
|
|
180
|
+
|
|
181
|
+
- Python 3.11 or higher
|
|
182
|
+
- pandas >= 2.0.0
|
|
183
|
+
- numpy >= 1.26.0
|
|
184
|
+
|
|
185
|
+
## Development
|
|
186
|
+
|
|
187
|
+
### Running Tests
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
uv run pytest
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Building Documentation
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
cd docs
|
|
197
|
+
uv run sphinx-build -b html . _build/html
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Contributing
|
|
201
|
+
|
|
202
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
203
|
+
|
|
204
|
+
## License
|
|
205
|
+
|
|
206
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|