Get integer row-index in dataframe where column matches specific value Get integer row-index in dataframe where column matches specific value pandas pandas

Get integer row-index in dataframe where column matches specific value


With boolean indexing, you can slice the dataframe to get only the rows where the date equals "2016-04-13" and get the index of the slice:

df[df.Date == "2016-04-13"].indexOut[37]: Int64Index([2], dtype='int64')

With the uniqueness assumption, there will be only one element in that array, so you can take the 0th element:

df[df.Date == "2016-04-13"].index[0]Out[38]: 2


Use df.index.get_loc('2016-04-14') to get the integer location for requested label. This will return 1 as intital starts from 0. So you can add one to get the index value as 2


df['Date'].values.tolist().index("2016-04-13") will return 2