Python version 3.8.5 / Pandas version 1.1.2
To display the rows of the indices from 0 to 99, I used
df[df.col_1 > 60].loc[range(0,99), 'col_2']
But I've got this error message
KeyError: "Passing list-likes to .loc or [] with any missing labels is no longer supported. The following labels were missing: Int64Index([ 1, 3, 4, 6, 7,\n ...\n 95, 96, 97, 98, 99],\n dtype='int64', length=72). See https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike"
For an alternative, I have this option which is working for my case:
df[df.col_1 > 2].loc[0:4, 'col_2']
I heard that it's no longer accepted for the new pandas version. Thanks for any confirmation.
I think here is better chain 2 masks by
&
and pass to oneloc
: