Skip to main content

Get a Pandas dataframe from SPARQL queries

Project description

sparqldataframe

image

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

sparqldataframe-0.1.3.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

sparqldataframe-0.1.3-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

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

Hashes for sparqldataframe-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e89e366e1a83a0a2c5037c772b6e360dbb9d82bf8b3fb50b756149600e51f606
MD5 962df08005cdbac6ae402d1a6320e853
BLAKE2b-256 45f027db45ada67ceff4c4b5d717ac1aeaf7bf5ed6d92c1a0a270d51743ce84e

See more details on using hashes here.

File details

Details for the file sparqldataframe-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for sparqldataframe-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a723aaa1a5568b17dc6a6ae41cbe5e18ec2dee0642e64eaccd11387de048dc2d
MD5 e341a5221c6c6e0f2e937300078a597d
BLAKE2b-256 10e06610cbb1e9d2962fef97d52a9144dd36d9f2d95ca809b17742680ffc89ad

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page