I am using Dataframe in python and trying to select row index based on multiple column values. Below is the 100th row's value of my dataframe:
>>> df.loc[100]
id 100
iid 9cdb7709-38f8-442a-812a-986b5b148161
lat -37.8294
lon 144.979
name Doryanthes excelsa
Name: 100, dtype: object
I want to select the rows whose id is 100 and lat is -37.8294 by below command:
>>> df[(df['id'] == 100) & (df['lat'] == -37.8294)].index
Int64Index([], dtype='int64')
the above command returns an empty index. I don't understand that I can get the value by df.loc[100] command but why can't I get the row index from the above command?
'lat'isn't a string or anthing like that? Your output would make me think that it is not finding anything that matches those conditions, and dtype inconsistencies is a common way for that to happen.print df['lat'].dtypeto check iirc.