def get_nearest_neighbours(p, N, i):
    """Return the nearest N neighbours to a given point, i

    Args:
        p (DataFrame): vertices dataframe
        N (int): integer for number of nearest neighbours to return
        i (int): loc within dataframe p

    Returns:
        a tuple of locs of the nearest neighbours
    """
    # p_new will be the returned dataframe
    p_new = p.copy()
    # calculate distances to other points
    vecs = p_new[["x", "y", "z"]] - p[["x", "y", "z"]].loc[i]
    dists = vecs.x**2 + vecs.y**2 + vecs.z**2
    # merge distances into the p_new
    dists = dists.to_frame(name='dist2')
    p_new = p_new.join(dists)
    p_new.sort_values(by='dist2', inplace=True)
    return p_new.iloc[1:N+1]