The rank() function converts np.nan to np.inf or -np.inf, and therefore can't properly rank existing np.inf. See here: #6886 (comment).
Test for this issue here: https://github.com/pydata/pandas/blob/master/pandas/tests/test_series.py#L4071