1

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]) 

2 Answers 2

3

idxmax returns the index, so you need loc, not iloc:

data.loc[data['LOCALGBUSED'].idxmax()] 
Sign up to request clarification or add additional context in comments.

Comments

1

.iloc should Just use .idxmax() with .loc:

data.loc[data['LOCALGBUSED'].idxmax()] 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.