Month: December 2021

GitHub statistics for DTU Compute researchers

Posted on

DTU Compute is a department at the Technical University of Denmark. How many followers does DTU Compute researchers have? This Python code attempts to answer that question.

Code

This is based on the code at my previous blogpost Female GitHubbers.

import re
import requests
import pandas as pd
from time import sleep

query = """
SELECT
  ?researcher ?researcherLabel ?researcherDescription
  (SAMPLE(?github_) AS ?github)
WITH {
  SELECT DISTINCT ?researcher WHERE {
    ?researcher ( wdt:P108 | wdt:P463 | wdt:P1416 ) / wdt:P361* wd:Q23048689 . 
  } 
} AS %researchers
WHERE {
  INCLUDE %researchers
  ?researcher wdt:P2037 ?github_ .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,nl,no,ru,sv,zh" . } 
}
GROUP BY ?researcher ?researcherLabel ?researcherDescription 
"""
response = requests.get("https://query.wikidata.org/sparql",
                        params={'query': query, 'format': 'json'})
researchers = pd.json_normalize(response.json()['results']['bindings'])


URL = "https://api.github.com/users/"
followers = []
for github in researchers['github.value']:
    if not re.match('^[a-zA-Z0-9]+$', github):
        followers.append(0)
        continue
    url = URL + github
    print(url)
    try:
        response = requests.get(url,
                                headers={'Accept':'application/vnd.github.v3+json'})
        user_followers = response.json()['followers']     
    except:
        user_followers = 0
    followers.append(user_followers)
    print("{} {}".format(github, followers))
    sleep(5)


researchers['followers'] = followers
columns = ['followers', 'github.value', 'researcherLabel.value',
           'researcher.value']

print(researchers.sort_values(['followers'], ascending=False)[columns].to_html(index=False))

Results

As is apparent from the code, the statistics is based on the labelling in Wikidata which is likely incomplete, meaning that people not occurring on the list might not be on GitHub, may not be recorded in Wikidata as on GitHub, or may not be recorded as being associated with DTU Compute.

followersgithub.valueresearcherLabel.valueresearcher.value
555andersbllAnders Boesen Lindbo Larsenhttp://www.wikidata.org/entity/Q28829121
537rasmusbergpalmRasmus Berg Palmhttp://www.wikidata.org/entity/Q42189239
179fnielsenFinn Årup Nielsenhttp://www.wikidata.org/entity/Q20980928
79SkafteNickiNicki Skafte Detlefsenhttp://www.wikidata.org/entity/Q57080372
57larsmaaloeeLars Maaløehttp://www.wikidata.org/entity/Q29016760
35h0pbeatArkadiusz Stopczynskihttp://www.wikidata.org/entity/Q28045211
33sunemanSune Lehmannhttp://www.wikidata.org/entity/Q24390693
26pmorenozPablo Moreno-Muñozhttp://www.wikidata.org/entity/Q90363825
24janbaJakob Andreas Bærentzenhttp://www.wikidata.org/entity/Q25939218
19apengsigkarupAllan P. Engsig-Karuphttp://www.wikidata.org/entity/Q24449285
16baekgaardPer Bækgaardhttp://www.wikidata.org/entity/Q28045348
12BonnevieRasmus Bonneviehttp://www.wikidata.org/entity/Q28681282
8bardramJakob E. Bardramhttp://www.wikidata.org/entity/Q24389216
5sfvnielsenSøren Føns Vind Nielsenhttp://www.wikidata.org/entity/Q28948833
5SThereseSofie Therese Hansenhttp://www.wikidata.org/entity/Q28477916
4MichaelRiisMichael Riis Andersenhttp://www.wikidata.org/entity/Q30169795
3bjarkemoenstedBjarke Mønstedhttp://www.wikidata.org/entity/Q56120499
1KristofferAlbersKristoffer Jon Albershttp://www.wikidata.org/entity/Q28845839
1michaelkaipetersenMichael Kai Petersenhttp://www.wikidata.org/entity/Q24573646
0andrea-cuttoneAndrea Cuttonehttp://www.wikidata.org/entity/Q28045195
0jakobeglarsenJakob Eg Larsenhttp://www.wikidata.org/entity/Q25931571
0North-GuardJeppe Nørregaardhttp://www.wikidata.org/entity/Q44738835
0laura-riegerLaura Riegerhttp://www.wikidata.org/entity/Q48975801
0letizia-marchegianiLetizia Marchegianihttp://www.wikidata.org/entity/Q56363348
0ekkartEkkart Kindlerhttp://www.wikidata.org/entity/Q25939354

The two top listings, Anders Boesen Lindbo Larsen and Rasmus Berg Palm, are no longer at DTU Compute, as far as I can tell.