Reputation: 189
Using the describe() function I have noted the max value, 1350 in this case, that is present in my column 'LOCALGBUSED', but as my dataframe contains millions of rows, how do I find the index that holds that value?
count 3483638.000000
mean 149.145475
std 206.053277
min 0.000000
25% 6.000000
50% 80.000000
75% 200.000000
max 1350.000000
Name: LOCALGBUSED, dtype: object
I tried using this code to get the index of the max value of that column rather then the value itself, but the index it displayed did not contain the listed max value of 1350
column = data['LOCALGBUSED']
max_index = column.idxmax()
print(max_index)
index # from code above
print(data.iloc[397386])
Upvotes: 1
Views: 42
Reputation: 15518
.iloc
should Just use .idxmax()
with .loc
:
data.loc[data['LOCALGBUSED'].idxmax()]
Upvotes: 1
Reputation: 150815
idxmax
returns the index, so you need loc
, not iloc
:
data.loc[data['LOCALGBUSED'].idxmax()]
Upvotes: 3