Skip to main content

RDFLib SPARQL DataFrame

Export results from an rdflib SPARQL query into a pandas.DataFrame, using Python types.

Taken from https://github.com/RDFLib/sparqlwrapper/issues/125#issuecomment-704291308 resp. https://github.com/RDFLib/rdflib/issues/1179#issuecomment-704299074 .

Install

pip install rdflib-sparql-dataframe
# or
poetry add rdflib-sparql-dataframe

Use

from rdflib import Graph
from rdflib_sparql_dataframe import sparql_results_to_df

data = """
@prefix ex: <https://example.org/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

ex:Petra a foaf:Person ;
  foaf:name "Petra" ;
  foaf:knows ex:Peter .

ex:Peter a foaf:Person ;
  foaf:name "Peter" .
"""

query = """
prefix foaf: <http://xmlns.com/foaf/0.1/>
select ?person ?name ?friend ?friendname {
  ?person foaf:name ?name ;
    foaf:knows ?friend .
  ?friend foaf:name ?friendname .
}
"""

graph = Graph()
graph.parse(data=data)

dataframe = sparql_results_to_df(graph.query(query))

Metadata

Release files for rdflib-sparql-dataframe 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rdflib-sparql-dataframe 1.0.2
File Size Uploaded Provenance Actions
rdflib_sparql_dataframe-1.0.2.tar.gz 5.4 kB Without provenance Details for rdflib_sparql_dataframe-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rdflib-sparql-dataframe 1.0.2
File Interpreter ABI Platform Actions
rdflib_sparql_dataframe-1.0.2-py3-none-any.whl Python 3 none any Details for rdflib_sparql_dataframe-1.0.2-py3-none-any.whl

Total release size: 11.6 kB

Release files / rdflib_sparql_dataframe-1.0.2.tar.gz

Download URL rdflib_sparql_dataframe-1.0.2.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8d4a3427f02fa8124dec6e7523bba9fe87ab1a5729bf1015f507935e31973cb9
BLAKE2b-256 checksum
How to use checksums
a777a8cc5e119b040ef8d283170ff9534ae25df2c26ba9309a3acdb6537ab6e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Linux/6.13.5-200.fc41.x86_64

Release files / rdflib_sparql_dataframe-1.0.2-py3-none-any.whl

Download URL rdflib_sparql_dataframe-1.0.2-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f71fa1db2537ae99a7e67f6d947f09d253930ee0ba7c49e8f3f9a3e02e034373
BLAKE2b-256 checksum
How to use checksums
5161a5c8573b062e79f34a24050c24c9545d8eae6910f6ea20d3fd09f2f46c14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Linux/6.13.5-200.fc41.x86_64

Security for rdflib-sparql-dataframe 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page