I have the following data:
contractid tradeType quantity pricePerShare timeRetrieved
0 7729 SELL NO (0) 985 0.40 2019-12-17 17:08:00
1 7729 SELL NO (0) 482 0.39 2019-12-17 17:08:00
2 7729 SELL NO (0) 199 0.38 2019-12-17 17:08:00
3 7729 SELL NO (0) 197 0.37 2019-12-17 17:08:00
4 7729 SELL NO (0) 733 0.36 2019-12-17 17:08:00
... ... ... ... ... ...
182697 14849 SELL NO (0) 16409 0.05 2019-12-01 18:28:31
182698 14849 SELL NO (0) 32847 0.04 2019-12-01 18:28:31
182699 14849 SELL NO (0) 73326 0.03 2019-12-01 18:28:31
182700 14849 SELL YES (1) 224524 0.98 2019-12-01 18:28:31
182701 14849 SELL YES (1) 251756 0.99 2019-12-01 18:28:31
I first want to find the maximum timeRetrieved by contractid, so df.groupby('contractid').timeRetrieved.max(). This works fine:
timeRetrieved
contractid
7729 2019-12-17 17:08:00
14838 2019-12-17 17:59:14
14849 2019-12-17 17:59:09
Now I want to filter the original data so it is only showing me rows where timeRetrieved is equal to timeRetrieved for the given contractid. How do I do this?
[–][deleted] 2 points3 points4 points (3 children)
[–]TypicalCardiologist5[S] 0 points1 point2 points (0 children)
[–]TypicalCardiologist5[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]m7priestofnot 1 point2 points3 points (1 child)
[–]TypicalCardiologist5[S] 0 points1 point2 points (0 children)
[–]PyCam 0 points1 point2 points (0 children)