{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exploring data with SPARQL"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"
\n",
"\n",
"---\n",
"\n",
"````{panels}\n",
":container: container-lg pb-3
\n",
":column: col-lg-3 col-md-4 col-sm-6 col-xs-12 p-1
\n",
":card: rounded
\n",
"\n",
"
\n",
"^^^\n",
"
Data Manager
\n", "Data Scientist
\n", "````\n", "\n", "---\n", "\n", "Background: \n", "\n", "Here, we show how to query the LinkedData graph using SPARQL to retrieve information about key study design design descriptors such as study group size and treatment groups." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import rdflib\n", "from rdflib import Graph, RDF\n", "from IPython.core.display import display, HTML\n", "import os\n", "import json\n", "import csv\n", "import uuid\n", "\n", "from SPARQLWrapper import SPARQLWrapper, SPARQLWrapper2, JSON, JSONLD, CSV, TSV, N3, RDF, RDFXML, TURTLE\n", "import pandas as pds\n", "import itertools\n", "\n", "import numpy as np\n", "from plotnine import *\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def queryResultToHTMLTable(queryResult):\n", " \n", " HTMLResult = '' + varName + ' | '\n", " HTMLResult = HTMLResult + '|
' + str(column) + ' | '\n", " else:\n", " HTMLResult = HTMLResult + '' + \"N/A\"+ ' | '\n", " HTMLResult = HTMLResult + '