How to find the lowest number of a grouped dataframe in Python
You can do:
df.groupby('leadid').agg({'hoursSinceContacted' : 'min'}).reset_index()
I have a table and I want to find the lowest number associated with each 'leadId' in my table. Here is a snapshot of it below:




Index
leadId
repId
hoursSinceContacted




1
261
1111
10391


2
261
2222
10247


3
261
3333
1149


4
261
4444
10247


5
262
5555
551


6
262
6666
982


6
262
3333
214




Is there a groupby statement I can use to get a table that looks like this?:




Index
leadId
repId
hoursSinceContacted




3
261
3333
1149


6
262
3333
214




Any suggestion will be much appreciated.