Pandas iloc vs loc: Selecting series values by position

Pandas iloc vs loc: Selecting series values by position

Retrieve from a Python Pandas series by position, rather than the index, with iloc:

s = pd.Series([10, 20, 30], index=list('abc'))
s.loc['a']         # 10
s.loc[['a', 'b']]  # series of a:10, b:20
s.iloc[0]          # 10
s.iloc[[0, 1]]     # series of a:10, b:20