Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return pandas object from query #41

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading