I have a simple index on my Dataframe (integers from 0:n).
If I want row index values 1,10,100, how do I query the index to get only those rows back?
Thanks
In your case, the index equals to integer position. Thus you can use either .loc or .iloc.
.loc is primarily label based...
.iloc is primarily integer position based (from 0 to length-1 of the axis)
See different-choices-for-indexing
Try this:
result = data.loc[[1,10,100]]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With