Answers for "how to get index of a value in pandas dataframe"

5

finding the index of an element in a pandas df

In [48]: a
Out[48]: 
   c1  c2
0   0   1
1   2   3
2   4   5
3   6   7
4   8   9

In [49]: a.c1[a.c1 == 8].index.tolist()
Out[49]: [4]
Posted by: Guest on September-18-2020
0

finding the index of an item in a pandas df

print(df[df['Name']=='Donna'].index.values)
Posted by: Guest on October-01-2020
1

get index number pandas dataframe

df.index[df['BoolCol'] == True].tolist()
Posted by: Guest on January-12-2021

Code answers related to "how to get index of a value in pandas dataframe"

Python Answers by Framework

Browse Popular Code Answers by Language