I solved this by recovering the (i,j) index from the k index in the functional.pdist.
The code:
def get_index(k, n):
    p = n-1
    kk = k
    j = 1
    i = 0
    while kk >= p:
        kk = kk-p
        p = p-1
        j += 1
        i += 1
    return i, j+kk