volume | price | datetime |
---|---|---|
100 | 3 | 2021-09-29 04:00:00-04:00 |
300 | 2 | 2021-09-29 04:30:00-04:00 |
900 | 5 | 2021-09-29 05:30:00-04:00 |
500 | 9 | 2021-09-29 06:00:00-04:00 |
900 | 22 | 2021-09-29 06:30:00-04:00 |
400 | 1 | 2021-09-29 07:00:00-04:00 |
return the price with the highest volume. if there are 2 volume that are same, then return the lower price ( it is 5 in this case)
Thanks in advance!!
CodePudding user response:
Here's one way. First, find the row(s) that have the max volume (I left out the datetime
column in these examples):
>>> df[df.volume == df.volume.max()]
volume price
2 900 5
4 900 22
Then use that result to find the lowest price:
>>> df[df.volume == df.volume.max()].price.min()
5