1- The .iloc indexer selects only by integer location and works
2similarly to Python lists.
3
4- The .loc indexer selects only by index label, which is
5similar to how Python dictionaries work.
1>>> s = pd.Series(list("abcdef"), index=[49, 48, 47, 0, 1, 2])
249 a
348 b
447 c
50 d
61 e
72 f
8
9>>> s.loc[0] # value at index label 0
10'd'
11
12>>> s.iloc[0] # value at index location 0
13'a'
14
15>>> s.loc[0:1] # rows at index labels between 0 and 1 (inclusive)
160 d
171 e
18
19>>> s.iloc[0:1] # rows at index location between 0 and 1 (exclusive)
2049 a
21
1iloc - default indexes (system generated)
2loc - table indexes or we manually given indexes