# Imports modules almost always used
from pprint import pprint
import requests

# Imports modules needed for a SPARQL query
import helper

# Imports modules to print the table
import pandas as pandas
import matplotlib as mpl
import matplotlib.pyplot as plt
# Define a SPARQL query
query = '''PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?teacher_id ?teacher ?teacher_idLabel ?name ?surname ?university_qualifier WHERE { # ?university ?email ?phone WHERE {
    ?teacher_id p:P31 ?istance_of_statement .								# ?teacher_id must have an "istance of" statement
    ?istance_of_statement ps:P31 wd:Q5 .									# that is "human".    
    ?teacher_id p:P106 ?occupation_statement .								# ?teacher_id must have an occupation
    ?occupation_statement ps:P106 wd:Q1622272 .          				 	# that is "university teacher"
  	?occupation_statement pq:P108 ?university_qualifier_element .				# the occupation can have as qualifier ?university_qualifier_element

  SERVICE wikibase:label {
     bd:serviceParam wikibase:language "en" .
   }
    OPTIONAL {
    	?teacher_id rdfs:label ?teacher filter(lang(?teacher) = "en") .											# ?teacher_id can have label ?teacher;
	?teacher_id p:P735 ?name_statement .									# ?teacher_id can have a name
	?name_statement ps:P735 ?name_element .								# that is ?name_element
	?name_element rdfs:label ?name filter(lang(?name) = "en").										# with label ?name;
    	?teacher_id p:P734 ?surname_statement .									# ?teacher_id can have a surname
	?surname_statement ps:P734 ?surname_element .							# that is ?surname_element
	?surname_element rdfs:label ?surname filter(lang(?surname) = "it")	.			# with label ?surname
    ?university_qualifier_element rdfs:label ?university_qualifier filter(lang(?university_qualifier) = "en")		 				# with label ?university_qualifier        					
                     
                     #wdt:P108 ?university . 				# ?teacher_id has worked for ?university
    }
}'''

# SPARQL endpoint
url = 'https://query.wikidata.org/bigdata/namespace/wdq/sparql'
# Get the data in JSON
data = requests.get(url, params={'query': query, 'format': 'json'}).json()

# JSON is structured this way
    # { 'head':     {'vars': ['SPARQL variable']},
    #   'results':  {'bindings': [{'SPARQL variable': {'type': 'literal',
    #                                                  'value': "SPARQL variable value for this result",
    #                                                  'xml:lang': 'en'},

# Initialize results
results = []

pprint(data['results']['bindings'])
# Populate results from JSON
for item in data['results']['bindings']:
    results.append({
        #'Name': item['name']['value'],
        'Cause of death': item['teacher_idLabel']['value'],
        'Date of birth': item['teacher_id']['value'],
        #'date of death': item['date_of_death']['value']
    })
[{'name': {'type': 'literal', 'value': 'Jonathan', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'Allen', 'xml:lang': 'it'},
  'teacher': {'type': 'literal',
              'value': 'Jonathan Moses Allen',
              'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q19953481'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Jonathan Moses Allen',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'Pennsylvania Medical College',
                           'xml:lang': 'en'}},
 {'name': {'type': 'literal', 'value': 'Sakari', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'Timonen', 'xml:lang': 'it'},
  'teacher': {'type': 'literal', 'value': 'Sakari Timonen', 'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q20249837'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Sakari Timonen',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'University of Helsinki',
                           'xml:lang': 'en'}},
 {'name': {'type': 'literal', 'value': 'José Luis', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'Serrano', 'xml:lang': 'it'},
  'teacher': {'type': 'literal',
              'value': 'José Luis Serrano Moreno',
              'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q22337713'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'José Luis Serrano Moreno',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'University of Granada',
                           'xml:lang': 'en'}},
 {'name': {'type': 'literal', 'value': 'Ernst', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'Ehrnrooth', 'xml:lang': 'it'},
  'teacher': {'type': 'literal',
              'value': 'Ernst Ehrnrooth',
              'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q11858491'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Ernst Ehrnrooth',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'University of Helsinki',
                           'xml:lang': 'en'}},
 {'name': {'type': 'literal', 'value': 'Joseph', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'Carson', 'xml:lang': 'it'},
  'teacher': {'type': 'literal', 'value': 'Joseph Carson', 'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q15677195'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Joseph Carson',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'Perelman School of Medicine at the '
                                    'University of Pennsylvania',
                           'xml:lang': 'en'}},
 {'name': {'type': 'literal', 'value': 'Alexander', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'Wolf', 'xml:lang': 'it'},
  'teacher': {'type': 'literal',
              'value': 'Alexander L. Wolf',
              'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q17102488'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Alexander L. Wolf',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'Imperial College London',
                           'xml:lang': 'en'}},
 {'name': {'type': 'literal', 'value': 'Kari', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'Niinistö', 'xml:lang': 'it'},
  'teacher': {'type': 'literal', 'value': 'Kari Niinistö', 'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q11869967'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Kari Niinistö',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'University of Turku',
                           'xml:lang': 'en'}},
 {'name': {'type': 'literal', 'value': 'Jonathan', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'Allen', 'xml:lang': 'it'},
  'teacher': {'type': 'literal',
              'value': 'Jonathan Adams Allen',
              'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q19953457'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Jonathan Adams Allen',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'Rush Medical College',
                           'xml:lang': 'en'}},
 {'name': {'type': 'literal', 'value': 'Arvo', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'Ylppö', 'xml:lang': 'it'},
  'teacher': {'type': 'literal', 'value': 'Arvo Ylppö', 'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q717543'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Arvo Ylppö',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'University of Helsinki',
                           'xml:lang': 'en'}},
 {'name': {'type': 'literal', 'value': 'Stephen', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'Webber', 'xml:lang': 'it'},
  'teacher': {'type': 'literal', 'value': 'Stephen Webber', 'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q19672826'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Stephen Webber',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'Berklee College of Music',
                           'xml:lang': 'en'}},
 {'name': {'type': 'literal', 'value': 'William', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'Shippen', 'xml:lang': 'it'},
  'teacher': {'type': 'literal',
              'value': 'William Shippen',
              'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q8018403'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'William Shippen',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'Perelman School of Medicine at the '
                                    'University of Pennsylvania',
                           'xml:lang': 'en'}},
 {'name': {'type': 'literal', 'value': 'Thomas', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'James', 'xml:lang': 'it'},
  'teacher': {'type': 'literal',
              'value': 'Thomas Chalkley James',
              'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q19828335'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Thomas Chalkley James',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'Perelman School of Medicine at the '
                                    'University of Pennsylvania',
                           'xml:lang': 'en'}},
 {'name': {'type': 'literal', 'value': 'Paulo', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'Morais', 'xml:lang': 'it'},
  'teacher': {'type': 'literal',
              'value': 'Paulo de Morais',
              'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q18697787'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Paulo de Morais',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'Oporto Global University',
                           'xml:lang': 'en'}},
 {'name': {'type': 'literal', 'value': 'Paulo', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'Morais', 'xml:lang': 'it'},
  'teacher': {'type': 'literal',
              'value': 'Paulo de Morais',
              'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q18697787'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Paulo de Morais',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'INESC TEC',
                           'xml:lang': 'en'}},
 {'name': {'type': 'literal', 'value': 'Oswald', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'Renkonen', 'xml:lang': 'it'},
  'teacher': {'type': 'literal',
              'value': 'Oswald Renkonen',
              'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q13223627'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Oswald Renkonen',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'University of Helsinki',
                           'xml:lang': 'en'}},
 {'name': {'type': 'literal', 'value': 'Angelo', 'xml:lang': 'en'},
  'surname': {'type': 'literal', 'value': 'Gatti', 'xml:lang': 'it'},
  'teacher': {'type': 'literal', 'value': 'Angelo Gatti', 'xml:lang': 'en'},
  'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q3617017'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Angelo Gatti',
                      'xml:lang': 'en'},
  'university_qualifier': {'type': 'literal',
                           'value': 'University of Pisa',
                           'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q233976'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Frederick Hopkins',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q1697323'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'J.J. Mikkola',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q3361462'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Juha Pentikäinen',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q3731662'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Erieta Attali',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q4792887'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Armas Otto Väisänen',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q5408218'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Nils Oker-Blom',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q5491926'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Tapio Tarjanne',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q6084692'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Martti Ruuth',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q8059647'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Yrjö Blomstedt',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q12617992'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Ji Sang-wook',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q13569941'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Juha Hernesniemi',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q19517296'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Samuel Jackson',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q19819826'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Thomas Harrison Montgomery, Jr.',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q26721101'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Viera Němejcová-Pavúková',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q78448'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Heinz Hopf',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q116176'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Ernst Stueckelberg',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q154655'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Vere Gordon Childe',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q656478'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Benjamin Rush',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q799712'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Bae Bien-u',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q1123687'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Zoltán Kása',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q1248733'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Georg Daltrop',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q2093857'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Pierre Riché',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q2093857'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Pierre Riché',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q3174395'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Jean Rohou',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q4007892'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Valerio Mariani',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q4403376'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Kaija Saarikettu',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q4403376'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Kaija Saarikettu',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q5485137'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Frank B. Wynn',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q5659947'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Paulino Savirón Caravantes',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q5819000'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Matti Hyökki',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q5919559'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Sixten Korkman',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q6089789'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Esko Salminen',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q8016445'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'William P. C. Barton',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q11890486'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Reino Kurki-Suonio',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q11892464'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Sara Heinämaa',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q12407204'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Zahava Solomon',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q12625846'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Hwang SunHye',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q15525727'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Bruno Siciliano',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q15728447'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Janusz Wojtusiak',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q15698809'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'George Bacon Wood',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q15698809'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'George Bacon Wood',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q15996480'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Ransom Asa Moore',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q16090695'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Lee Kyungsook',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q16989418'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Heikki Niskakangas',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q16990896'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Martti Tiuri',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q17380495'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Pekka Halonen',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q19648800'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'William Warder Cadbury',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q19832254'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Monica Claes',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q21263395'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Lee Manjai',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q21263395'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Lee Manjai',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q21263395'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Lee Manjai',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q21328667'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Annebella Pollen',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q21684470'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'José Luis Sirera',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q22105603'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Germain Colladon',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q26768584'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Werner Schubert',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q26932951'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Kees Kaan',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q27559542'},
  'teacher_idLabel': {'type': 'literal', 'value': 'Q27559542'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q28874626'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Victor von Dantscher',
                      'xml:lang': 'en'}},
 {'teacher_id': {'type': 'uri',
                 'value': 'http://www.wikidata.org/entity/Q28054713'},
  'teacher_idLabel': {'type': 'literal',
                      'value': 'Donna C. Kurtz',
                      'xml:lang': 'en'}}]
# Print the table
infosize = 12
dataframe = pandas.DataFrame(results)
print(len(dataframe))
dataframe.head()
75
Cause of death Date of birth
0 Frederick Gowland Hopkins http://www.wikidata.org/entity/Q233976
1 Q1697323 http://www.wikidata.org/entity/Q1697323
2 Q3361462 http://www.wikidata.org/entity/Q3361462
3 Erieta Attali http://www.wikidata.org/entity/Q3731662
4 Q4792887 http://www.wikidata.org/entity/Q4792887
#Stampa i dati
pprint(data)