DataFrame to RDF conversion

rumo converts a DataFrame to RDF in the Turtle format. The command-line tool, pyrumo.to_turtle and Rumo use the same conversion.

Conversion rules

  • Each row becomes a subject. The name of the subject is <base_url><row_stem><index>. The first index is 0.
  • Each column becomes a property. The name of the property is <base_url><column name>.
  • Each cell becomes one triple: the row, the column property and the value.

Values

DataFrame typeTurtle valueExample
StringQuoted string"Alice"
IntegerNumber without quotes25
FloatNumber with a decimal point92.0
NullEmpty string""
Other typesThe Polars text formtrue

Example

This table:

nameagescore
Alice2588.5
Bob3092.0

gives this Turtle text with base_url="http://example.org/" and row_stem="r":

prefix : <http://example.org/>

:r0 :name "Alice" ;
    :age 25 ;
    :score 88.5 .
:r1 :name "Bob" ;
    :age 30 ;
    :score 92.0 .

In a rule program, these triples have this form:

data(<http://example.org/r0>, <http://example.org/name>, "Alice")

Use a @prefix statement in the rules to write the IRIs in a short form:

@prefix : <http://example.org/> .
young(?name) :- data(?r, :name, ?name), data(?r, :age, ?age), ?age < 28 .

Limitations

Refer to Limitations and troubleshooting.