rdfpandas package

Submodules

rdfpandas.graph module

rdfpandas.graph.to_dataframe(g: rdflib.graph.Graph) → pandas.core.frame.DataFrame[source]

Takes rdfLib Graph object and creates Pandas DataFrame. Indices are subjects and attempt is made to construct CURIEs using namespace manager of the rdfLib Graph. Columns are predicates and attempt is made to construct CURIEs using namespace manager of the rdfLib Graph, similar to indices. Column names are created using “predicate{rdfLib Identifier instance class name}(type)[index]@language” pattern to allow for round trip conversion. Multiple objects for the same subject and predicate result in columns with index in its name. No attemps are made at type conversion, all objects are strings in the DataFrame.

g : rdflib.Graph
rdfLib Graph.
pd.DataFrame
Pandas DataFrame created from rdfLib Graph.
rdfpandas.graph.to_graph(df: pandas.core.frame.DataFrame, namespace_manager: rdflib.namespace.NamespaceManager = None) → rdflib.graph.Graph[source]

Takes Pandas DataFrame and returns RDFLib Graph. Row indices are used as subjects and column indices as predicates. Object types are inferred from the column index pattern of “predicate{rdfLib Identifier instance class name}(type)[index]@language”. Index numbers simply create additoinal statements as opposed to attempting to construct a new rdfs:List or rdfs:Container. Namespaces need to be bound by the user of the method prior to serialization.

df : pandas.DataFrame
DataFrame to be converted into Graph.
namespace_manager : rdflib.namespace.NamespaceManager
NamespaceManager to use to normalize URIs
rdflib.Graph
Graph created from Pandas DataFrame.

Module contents