Pandas Series selection speed: iloc[:2] beats loc and head

Pandas Series selection speed: iloc[:2] beats loc and head

What’s the fastest way to retrieve the first 2 items from a Python Pandas series?

s = pd.Series([10, 20, 30], index=list('abc'))
s.loc[['a','b']] # 108 µs
s.loc['a':'b']   #  22.7 µs
s.iloc[[0, 1]]   #  26.7 µs
s.iloc[:2]       #  18 µs
s.head(2)        #  22.3 µs