datasets_sql
A 🤗 Datasets extension package that provides support for executing arbitrary SQL queries on HF datasets. It uses DuckDB as a SQL engine and follows its query syntax.
Installation
pip install datasets_sql
Quick Start
from datasets import load_dataset, Dataset
from datasets_sql import query
imdb_dset = load_dataset("imdb", split="train")
# Remove the rows where the `text` field has less than 1000 characters
imdb_query_dset1 = query("SELECT text FROM imdb_dset WHERE length(text) > 1000")
# Count the number of rows per label
imdb_query_dset2 = query("SELECT label, COUNT(*) as num_rows FROM imdb_dset GROUP BY label")
# Remove duplicated rows
imdb_query_dset3 = query("SELECT DISTINCT text FROM imdb_dset")
# Get the average length of the `text` field
imdb_query_dset4 = query("SELECT AVG(length(text)) as avg_text_length FROM imdb_dset")
order_customer_dset = Dataset.from_dict({
"order_id": [10001, 10002, 10003],
"customer_id": [3, 1, 2],
})
customer_dset = Dataset.from_dict({
"customer_id": [1, 2, 3],
"name": ["John", "Jane", "Mary"],
})
# Join two tables
join_query_dset = query(
"SELECT order_id, name FROM order_customer_dset INNER JOIN customer_dset ON order_customer_dset.customer_id = customer_dset.customer_id"
)
Metadata
Release files for datasets-sql 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| datasets_sql-0.4.0.tar.gz | 9.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| datasets_sql-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.3 kB
Release files / datasets_sql-0.4.0.tar.gz
| Download URL | datasets_sql-0.4.0.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d68fb0f5718d66ce6c9a5249400cefa69be0567ce13ce1514b10f8857036943f
|
|
BLAKE2b-256 checksum How to use checksums |
776062f680f0b4aad9ccbbd08f0885d55eb1d214b21e86fd08d319ad76b36246
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.18
|
Release files / datasets_sql-0.4.0-py3-none-any.whl
| Download URL | datasets_sql-0.4.0-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e039965fa6519cab5d8e93e685f081ee27f62b68c634cf92d9a5ebb13163cc30
|
|
BLAKE2b-256 checksum How to use checksums |
2f79faea9bde92a8ec329934998a56f6a68d25b60da39ef9af0a1d38619fe772
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.18
|