dataframe_to_triples¶
-
ampligraph.utils.
dataframe_to_triples
(X, schema)¶ Convert DataFrame into triple format.
- Parameters
X (pandas DataFrame with headers) –
schema (List of (subject, relation_name, object) tuples) – where subject and object are in the headers of the data frame
Examples
>>> import pandas as pd >>> import numpy as np >>> from ampligraph.utils.model_utils import dataframe_to_triples >>> >>> X = pd.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv') >>> >>> schema = [['species', 'has_sepal_length', 'sepal_length']] >>> >>> dataframe_to_triples(X, schema)[0] array(['setosa', 'has_sepal_length', '5.1'], dtype='<U16')