Use iloc
for integer positional indexing
print(fls.iloc[1:3])
# 0.2 b
# 0.3 c
# dtype: object
Positional indexing begins at 0
. Unlike label-based indexing, but consistent with list slicing, the last position is excluded.
Use loc
for label-based indexing
print(fls.loc[0.1:0.3])
# 0.1 a
# 0.2 b
# 0.3 c
# dtype: object
There's only one index
There's no such thing as an "implicit index" or "explicit index". There's only one index:
print(fls.index)
# Float64Index([0.1, 0.2, 0.3, 0.4], dtype='float64')
Pandas provides methods to query this index by position (iloc
) or by label (loc
).