I need to find result as per the below condition from the sample dataframe given below:
| Datetime | Volume | Price |
|---|---|---|
| 2020-08-05 09:15:00 | 1033 | 504 |
| 2020-08-05 09:15:00 | 1960 | 516 |
| 2020-08-05 09:15:00 | 0 | 450 |
| 2020-08-05 09:15:00 | 1724 | 520 |
| 2020-08-05 09:15:00 | 0 | 500 |
| 2020-08-05 09:15:00 | 1870 | 540 |
| 2020-08-05 09:20:00 | 1024 | 476 |
| 2020-08-05 09:20:00 | 1980 | 548 |
| 2020-08-05 09:20:00 | 0 | 480 |
| 2020-08-05 09:20:00 | 1426 | 526 |
| 2020-08-05 09:20:00 | 0 | 586 |
| 2020-08-05 09:20:00 | 1968 | 588 |
- Find Price at Maximum Volume with group-by on Datetime Column.
- Calculate how many Price Values are below Price of Sl No 1 (ignoring rows with zero volume)
I want my result dataframe as below:
Datetime Volume Price Count_below_prc
2020-08-05 09:15:00 1960 516 1
2020-08-05 09:20:00 1980 548 2
For Datetime = 2020-08-05 09:15:00, only one value is below 516 (504, ignoring rows with zero volume) for Datetime = 2020-08-05 09:20:00, two values are below 548 (476 & 526, ignoring rows with zero volume)