Get a Pandas dataframe from SPARQL queries
Project description
sparqldataframe
A Python library that can send SPARQL queries to a SPARQL endpoint and retrieve a Pandas dataframe from the result.
Installation
pip install sparqldataframe
Usage
Here is an example how to run a SPARQL query on the Wikidata endpoint:
import sparqldataframe
sparql_query = """
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel
WHERE {
?item wdt:P31 wd:Q146.
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
}
}
"""
df = sparqldataframe.query(
"https://query.wikidata.org/sparql",
sparql_query)
Wikidata and DBPedia can be both used without
adding the SPARQL endpoint url by using the wikidata_query() and
dbpedia_query() functions respectively:
df = sparqldataframe.wikidata_query(sparql_query)
df = sparqldataframe.dbpedia_query(sparql_query)
License
This project is licensed under the MIT license. See the LICENSE for details.
Project details
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 sparqldataframe-0.1.3.tar.gz.
File metadata
- Download URL: sparqldataframe-0.1.3.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e89e366e1a83a0a2c5037c772b6e360dbb9d82bf8b3fb50b756149600e51f606
|
|
| MD5 |
962df08005cdbac6ae402d1a6320e853
|
|
| BLAKE2b-256 |
45f027db45ada67ceff4c4b5d717ac1aeaf7bf5ed6d92c1a0a270d51743ce84e
|
File details
Details for the file sparqldataframe-0.1.3-py3-none-any.whl.
File metadata
- Download URL: sparqldataframe-0.1.3-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a723aaa1a5568b17dc6a6ae41cbe5e18ec2dee0642e64eaccd11387de048dc2d
|
|
| MD5 |
e341a5221c6c6e0f2e937300078a597d
|
|
| BLAKE2b-256 |
10e06610cbb1e9d2962fef97d52a9144dd36d9f2d95ca809b17742680ffc89ad
|