Reputation: 175
If I have a dataframe like:
| number | dummy
------------------
0 | 1 | 45
1 | 5 | 435
2 | 10 | 112
3 | 7
4 | 8
5 | 9
How do I find the max value between index 2 and 4 under column 'number' which in this case is 10.
Upvotes: 3
Views: 1456
Reputation: 153460
If using index labels between 2 and 4 use loc
:
df.loc[2:4, 'number'].max()
Output:
10
If using index integer positions 2nd through the 4th labels, then use iloc
:
df.iloc[2:5, df.columns.get_loc('number')].max()
Note: you must use get_loc
to get the integer position of the column 'number'
Output:
10
Upvotes: 4