

Calculating the H-index of a researcher

This notebook shows how to use Python and the Dimensions Analytics API to calculate the H-index of a researcher.



A more precise definition:


How to calculate it:

Formally, if f is the function that corresponds to the number of citations for each publication, we compute the h-index as follows. First we order the values of f from the largest to the lowest value. Then, we look for the last position in which f is greater than or equal to the position (we call h this position). For example, if we have a researcher with 5 publications A, B, C, D, and E with 10, 8, 5, 4, and 3 citations, respectively, the h-index is equal to 4 because the 4th publication has 4 citations and the 5th has only 3. In contrast, if the same publications have 25, 8, 5, 3, and 3 citations, then the index is 3 because the fourth paper has only 3 citations (wikipedia)


This notebook assumes you have installed the Dimcli library and are familiar with the Getting Started tutorial.

!pip install dimcli -U --quiet

import dimcli
import pandas as pd
import sys

print("==\nLogging in..")
# https://github.com/digital-science/dimcli#authentication
ENDPOINT = "https://app.dimensions.ai"
if 'google.colab' in sys.modules:
  import getpass
  USERNAME = getpass.getpass(prompt='Username: ')
  PASSWORD = getpass.getpass(prompt='Password: ')
dsl = dimcli.Dsl()
Logging in..
Dimcli - Dimensions API Client (v0.7.4.2)
Connected to: https://app.dimensions.ai - DSL v1.27
Method: dsl.ini file

Selecting a researcher

Let’s take a researcher ID eg Michael Boutros ur.01357111535.49 and save its ID into a variable that can be referenced later.

Try modifying the researcher ID below to get different results!

RESEARCHER = "ur.01357111535.49"

The H-Index function

The h-Index function takes a list of citations and outputs the h-index value as explained above:

def the_H_function(sorted_citations_list, n=1):
    """from a list of integers [n1, n2 ..] representing publications citations,
    return the max list-position which is >= integer

    >>> the_H_function([10, 8, 5, 4, 3]) => 4
    >>> the_H_function([25, 8, 5, 3, 3]) => 3
    >>> the_H_function([1000, 20]) => 2
    if sorted_citations_list and sorted_citations_list[0] >= n:
        return the_H_function(sorted_citations_list[1:], n+1)
        return n-1

The H-index function is generic and can take any list of numbers representing publication citations.

Getting citations data from Dimensions

In order to pass some real-world data to the H-Index function, we can easily use the Dimensions API to extract all publication citations for a researcher, like this:

def get_pubs_citations(researcher_id):
    q = """search publications where researchers.id = "{}" return publications[times_cited] sort by times_cited limit 1000"""
    pubs = dsl.query(q.format(researcher_id))
    return list(pubs.as_dataframe().fillna(0)['times_cited'])

Wrapping things up

Finally, we combine the two functions to calculate the H-Index for a specific researcher:

print("H_index is:", the_H_function(get_pubs_citations(RESEARCHER)))
Returned Publications: 258 (total = 258)
Time: 0.53s
H_index is: 58

Where to find out more

Please have a look at the official documentation on searching for researchers for more information on this topic.

