Helper functions to run SQL on Pandas DataFrames
Project description
PDX2: Helper functions to run SQL on Pandas DataFrames
NOTE: This is basically a clone of https://github.com/ajfriend/pdx (since pdx is already taken on PyPI.)
pip install pdx2
Small ergonomic improvements to make it easy to run DuckDB queries on Pandas DataFrames.
pdx2monkey-patchespandas.DataFrameto provide adf.sql(...)method.- since
pdxuses DuckDB, you can leverage their convienient SQL dialect:
Query a Pandas DataFrame with df.sql(...).
Omit the FROM clause because it is added implicitly:
import pdx2
iris = pdx2.data.get_iris() # returns pandas.DataFrame
iris.sql("""
select
species,
count(*)
as num,
group by
1
""")
You can use short SQL (sub-)expressions because FROM and SELECT * are implied whenever they're omitted:
iris.sql('where petal_length > 4.5')
iris.sql('limit 10')
iris.sql('order by petal_length')
iris.sql('') # returns the dataframe unmodified. I.e., 'select * from iris'
For more, check out the example notebook folder.
Other affordances
df.aslist()df.asdict()df.asitem()df.cols2dict()- save/load helpers for DuckDB database files
Reference
For bleeding edge DuckDB
git clone https://github.com/duckdb/duckdb.git
cd duckdb
../env/bin/pip install -e tools/pythonpkg --verbose
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pdx2-0.11.0.tar.gz.
File metadata
- Download URL: pdx2-0.11.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
801bbf51fe736b9f78c56ff7383db6c6ceeeeb951b2ad466cafc643efa323b6c
|
|
| MD5 |
d63094f796d5b2d52b0f548802f9b0aa
|
|
| BLAKE2b-256 |
3ffb395567dfb388cce0a6435d25fefa43bfe1540f7fdb0f317aa360a3af2b40
|
Provenance
The following attestation bundles were made for pdx2-0.11.0.tar.gz:
Publisher:
pypi_publish.yml on ajfriend/pdx2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdx2-0.11.0.tar.gz -
Subject digest:
801bbf51fe736b9f78c56ff7383db6c6ceeeeb951b2ad466cafc643efa323b6c - Sigstore transparency entry: 165352172
- Sigstore integration time:
-
Permalink:
ajfriend/pdx2@63b0fa3bc83e43e88f5fe6c91df536afaa6ce6d1 -
Branch / Tag:
refs/tags/v0.11.0 - Owner: https://github.com/ajfriend
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@63b0fa3bc83e43e88f5fe6c91df536afaa6ce6d1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pdx2-0.11.0-py3-none-any.whl.
File metadata
- Download URL: pdx2-0.11.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5812bcc749fdb4a0c251c719da88192f992b03113c6f36e73dd7f4b1512e03b0
|
|
| MD5 |
b136a467fa3bb8d55edfbbb9affeeb21
|
|
| BLAKE2b-256 |
cea0d8f4e5365003c70817faeac91437457829ce67c4ed357ca9f2486016b963
|
Provenance
The following attestation bundles were made for pdx2-0.11.0-py3-none-any.whl:
Publisher:
pypi_publish.yml on ajfriend/pdx2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdx2-0.11.0-py3-none-any.whl -
Subject digest:
5812bcc749fdb4a0c251c719da88192f992b03113c6f36e73dd7f4b1512e03b0 - Sigstore transparency entry: 165352173
- Sigstore integration time:
-
Permalink:
ajfriend/pdx2@63b0fa3bc83e43e88f5fe6c91df536afaa6ce6d1 -
Branch / Tag:
refs/tags/v0.11.0 - Owner: https://github.com/ajfriend
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@63b0fa3bc83e43e88f5fe6c91df536afaa6ce6d1 -
Trigger Event:
release
-
Statement type: