Reputation: 4972
I need to get the value of the index and not an array following a criteria:
quarterValue = 20
indexOf = df[df["Quarter"]==quarterValue].index
The returning value is:
Int64Index([34], dtype='int64')
What I need is only:
34
Upvotes: 0
Views: 30
Reputation: 863301
Select first value by indexing:
idx = indexOf[0]
If possible sometimes is returned empty index solution failed, need trick with next
and iter
for first value with possible add default if no match:
idx = next(iter(indexOf), 'no value')
Upvotes: 1