I am trying to select a subset of the dataframe by choosing rows only if the Rank value is between 1 and 16 (including 1 and 16). I can achieve this with the following code:
ScimEn = ScimEn.loc[ScimEn["Rank"] < 16]
rankings = range(1,16)
ScimEn.loc[ScimEn["Rank"] in rankings]
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
You need to use 17 instead of 16 to get your desired condition.
rankings = range(1,17) ScimEn.loc[ScimEn["Rank"].isin(rankings)]