0

I have a kolas dataframe and I am trying to find out the index value of a specific record, but I keep getting the error "TypeError: 'Int64Index' object is not subscriptable". Below is the code which I tried.

kdf = ks.DataFrame({
    'id':[1,2,3,4],
    'A': [None, 3, None, None],
    'B': [2, 4, None, 3],
    'C': [99, None, None, 1],
    'D': [0, 1, 5, 4]
    },
    columns=['id','A', 'B', 'C', 'D'])
kdf.index[(kdf['id'] == 1)]
Nikesh
  • 47
  • 6

1 Answers1

0

try:

kdf = ps.DataFrame({
    'id':[1,2,3,4],
    'A': [None, 3, None, None],
    'B': [2, 4, None, 3],
    'C': [99, None, None, 1],
    'D': [0, 1, 5, 4]
},
    columns=['id','A', 'B', 'C', 'D'])
kdf.loc[(kdf['id'] == 1)].index
G.G
  • 639
  • 1
  • 5