Skip to main content

RDF support for Pandas

Project description

RdfPandas is a module providing RDF support for Pandas. It consists of two simple functions for Graph to DataFrame conversion and DataFrame to Graph conversion.

Getting Started

For more information about Resource Description Framework (RDF) and Pandas see:


You will need Python 3 to use Pandas and RdfPandas.


pip install rdfpandas


Creating RDF from DataFrame

As of version 1.1.0 NamespaceManager can be supplied to rdflib.to_graph for conversion to Graph.

import rdfpandas.graph
import pandas as pd
import rdflib

df = pd.read_csv('to_graph_test.csv', index_col = '@id', keep_default_na = False)
namespace_manager = NamespaceManager(Graph())
namespace_manager.bind('skos', SKOS)
namespace_manager.bind('rdfpandas', Namespace(''))
g = to_graph(df, namespace_manager)
s = g.serialize(format = 'turtle')

Creating DataFrame from RDF

import rdfpandas.graph
import pandas as pd
import rdflib

g = rdflib.Graph()
g.parse('to_df_test.ttl', format = 'ttl')
df = to_dataframe(g)
df.to_csv('test.csv', index = True, index_label = "@id")


No special effort is made for dealing with types, so please be aware of Pandas features such as that may result in surprising RDF statements like "10.0"^^<xsd:integer>.

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

rdfpandas-1.1.0.tar.gz (5.5 kB view hashes)

Uploaded source

Built Distribution

rdfpandas-1.1.0-py3-none-any.whl (5.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page