itertools.islice would be faster than n*comparisons here: https://github.com/pydata/pandas/blob/88c4c5526b38194f00a00c207ee5388dfd508092/pandas/core/frame.py#L759 Not sure whether to amortize an `import itertoosl` or not.