Month: December 2021
GitHub statistics for DTU Compute researchers
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.
The two top listings, Anders Boesen Lindbo Larsen and Rasmus Berg Palm, are no longer at DTU Compute, as far as I can tell.