Convert a pandas.core.indexes.numeric.Int64Index to an integer

Question:

I used the below code to return the index of a unique ID value

n = df.index[df['ID'] == 55555]

but n is a value of type pandas.core.indexes.numeric.Int64Index but I need it as an integer to complete the code below.

df.at[n, 'Name'] = 'John'

how can i extract the integer value of n ?

Asked By: Samir112

||

Answers:

You can just call [0]

df.at[n[0], 'Name'] = 'John'
Answered By: BENY
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.