Skip to content

Commit

Permalink
return pandas object from query
Browse files Browse the repository at this point in the history
  • Loading branch information
srmnitc committed Jul 6, 2023
1 parent 3b9b790 commit 44f4d46
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion pyscal_rdf/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import inspect
from ase.io import write
import copy
import pandas as pd

from pyscal_rdf.visualize import visualize_graph
from pyscal_rdf.network import OntologyNetwork
Expand Down Expand Up @@ -864,7 +865,28 @@ def to_file(self, sample, filename=None, format="lammps-dump"):
#write(filename, asesys, format=format)
sys.to_file(filename, format=format)



def query(self, inquery):
"""
Query the graph using SPARQL
Parameters
----------
inquery: string
SPARQL query to be executed
Returns
-------
res: pandas DataFrame
pandas dataframe results
"""
res = self.graph.query(inquery)
if res is not None:
return pd.DataFrame(res)
raise ValueError("SPARQL query returned None")



def query_sample(self, target_property, value, return_query=False):
"""
Query the Graph for a sample that has the given `value` for the given `target_property`
Expand Down

0 comments on commit 44f4d46

Please sign in to comment.