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

Convert SPARQLWrapper.SmartWrapper to pandas dataframe #205

Open
appliedgraphs opened this issue Mar 12, 2022 · 6 comments
Open

Convert SPARQLWrapper.SmartWrapper to pandas dataframe #205

appliedgraphs opened this issue Mar 12, 2022 · 6 comments

Comments

@appliedgraphs
Copy link

I want to convert a SmartWrapper to a pandas DF. We have two relevant issues:

  • #125 Which is focused on a SPARQLResult
  • #1179 - which also seems to be about SPARQLRest

My goal is to execute a SPARQL query, get a result, and then transform to a dataframe. I am certain that I am missing something because this must be a very common need.

@nicholascar
Copy link
Member

nicholascar commented Mar 13, 2022

@appliedgraphs have you seen this existing script: https://github.com/RDFLib/sparqlwrapper/blob/master/SPARQLWrapper/sparql_dataframe.py

@afk314
Copy link

afk314 commented Mar 13, 2022

I hadn't, but it's nice and easy to follow. It also works wonderfully! What can be done to make this easier to find or otherwise more integrated with rdflib?

@nicholascar
Copy link
Member

Yes, I think PANDAS is well known enough to be supported as a standard output option. The only hitch is that we want to ensure basic installation of SPARQLWrapper doesn't require PANDAS, since it's large, so it can be included but a pip install optional will need to be made to enable it.

Something like pandas[pandas] in requirements.txt and then pip install sparqlwrapper[pandas] to install.

Would love to see a PR for this...

@eggplants
Copy link
Contributor

@nicholascar Already:

sparqlwrapper/setup.cfg

Lines 53 to 54 in 2a6e2d3

pandas =
pandas>=1.3.5

@nicholascar
Copy link
Member

Great, thanks @eggplants, so the installation tasks are already done. So, I suppose, a deeper integration of PANDAS could be made, as long as appropriate warnings are thrown if users try and call PANDAS exports without the necessary installation.

@WolfgangFahl
Copy link

this is what pyLodStorage was motivated by https://github.com/WolfgangFahl/pyLoDStorage where you get list of dicts that you can immediately use in pandas see #160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants