I have a pandas datastructure, which I create like this:
test_inputs = pd.read_csv(\"../input/test.csv\", delimiter=\',\')
Its shape
Indexing in pandas is really confusing, as it looks like list indexing but it is not. You need to use .iloc
, which is indexing by position
print(test_inputs.iloc[100:200, :])
And if you don't use column selection you can omit it
print(test_inputs.iloc[100:200])
P.S. Using .loc
(or just []
) is not what you want, as it would look not for the row number, but for the row index (which can be filled we anything, not even numbers, not even unique). Ranges in .loc
will find rows with index value 100 and 200, and return the lines between. If you just created the DataFrame .iloc
and .loc
may give the same result, but using .loc
in this case is a very bad practice as it will lead you to difficult to understand problem when the index will change for some reason (for example you'll select some subset of rows, and from that moment the row number and index will not be the same).