RDFPandas, providing RDF support for Pandas #1734
ghost
started this conversation in
Show and tell
Replies: 1 comment
-
Very interesting. I'm curious what the equivalent functionality is for sending the triples in a graph to a DataFrame? As a first try, I'd think something like this? g = Graph()
g.parse('test.ttl')
p = pd.DataFrame()
for stmt in g:
p = pd.concat([p, pd.DataFrame({'s': [stmt[0]], 'p': [stmt[1]], 'o': [stmt[2]]})]) For a graph with 10,000 triples this is pretty efficient but for larger graphs it seems to take longer. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
RdfPandas
RdfPandas is a module providing RDF support for Pandas. It consists of two simple functions for
Graph
toDataFrame
conversion andDataFrame
toGraph
conversion.Creating RDF from DataFrame
As of version 1.1.0 NamespaceManager can be supplied to
rdflib.to_graph
for conversion to Graph.Creating DataFrame from RDF
Gotchas
No special effort is made for dealing with types, so please be aware of Pandas features such as https://pandas.pydata.org/pandas-docs/stable/user_guide/gotchas.html#support-for-integer-na that may result in surprising RDF statements like
"10.0"^^<xsd:integer>
.Beta Was this translation helpful? Give feedback.
All reactions