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
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
sparqldataframe-0.1.2.tar.gz
(3.8 kB
view hashes)
Built Distribution
Close
Hashes for sparqldataframe-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dd0665d2f3bf9fe79c74d6426712deaedcb0f68cd049e5b0c3c4c21bd2409d9 |
|
MD5 | 041a22a4dda538eed91bc8df532fb271 |
|
BLAKE2b-256 | 88d79e8b16a443b75e27f5c12751e8de2cb3ba40cd9dbe2cd2d58b1770f7c82a |