How would you be able to pull the highest number in the hi column between the "12/10/2021 9:30" row and the "12/10/2021 10:00" row?
The output of the panda's data frame:
date hi lo open close volume
12/10/2021 9:10 175.4 175.31 175.39 175.32 1889
12/10/2021 9:11 175.48 175.34 175.34 175.48 3449
12/10/2021 9:12 175.47 175.42 175.47 175.42 890
12/10/2021 9:13 175.46 175.4 175.43 175.44 5815
12/10/2021 9:14 175.48 175.42 175.42 175.48 7983
12/10/2021 9:15 175.5 175.44 175.48 175.44 5813
12/10/2021 9:16 175.44 175.35 175.44 175.38 9524
12/10/2021 9:17 175.38 175.25 175.35 175.38 8514
12/10/2021 9:18 175.48 175.38 175.41 175.48 4313
12/10/2021 9:19 175.45 175.39 175.45 175.41 14117
12/10/2021 9:20 175.43 175.36 175.36 175.36 8298
12/10/2021 9:21 175.39 175.32 175.37 175.39 2768
12/10/2021 9:22 175.4 175.34 175.39 175.38 4721
12/10/2021 9:23 175.41 175.37 175.39 175.37 3563
12/10/2021 9:24 175.49 175.41 175.42 175.49 1989
12/10/2021 9:25 175.48 175.25 175.41 175.26 15013
12/10/2021 9:26 175.3 175.15 175.26 175.18 7241
12/10/2021 9:27 175.26 175.1 175.16 175.16 23590
12/10/2021 9:28 175.19 175.1 175.12 175.15 10780
12/10/2021 9:29 175.27 175.15 175.15 175.23 12863
12/10/2021 9:30 176.03 175.14 175.25 175.71 1370478
12/10/2021 9:31 175.9 175.46 175.71 175.9 435577
12/10/2021 9:32 176.1 175.68 175.88 175.73 485381
12/10/2021 9:33 175.87 175.37 175.74 175.615 450575
12/10/2021 9:34 176.1 175.52 175.609 176.05 485467
12/10/2021 9:35 176.11 175.54 176.06 175.64 484336
12/10/2021 9:36 176.15 175.51 175.65 176.005 462430
12/10/2021 9:37 176.32 175.87 175.992 176.17 502685
12/10/2021 9:38 176.53 176.14 176.165 176.47 668669
12/10/2021 9:39 176.556 176.345 176.48 176.367 577773
12/10/2021 9:40 176.42 176.005 176.35 176.005 388618
12/10/2021 9:41 176.05 175.66 176.01 176.01 511461
12/10/2021 9:42 176.03 175.81 176.011 175.89 277475
12/10/2021 9:43 176.215 175.88 175.908 176.188 315341
12/10/2021 9:44 176.45 176.01 176.18 176.025 426582
12/10/2021 9:45 176.36 175.88 176.02 175.935 513756
12/10/2021 9:46 176.03 175.76 175.94 175.8 367906
12/10/2021 9:47 175.775 175.45 175.775 175.56 481068
12/10/2021 9:48 175.76 175.45 175.55 175.739 369607
12/10/2021 9:49 175.89 175.56 175.73 175.66 290529
12/10/2021 9:50 175.86 175.55 175.66 175.83 310516
12/10/2021 9:51 176.12 175.81 175.84 176.01 428011
12/10/2021 9:52 176.06 175.721 176.015 175.83 275272
12/10/2021 9:53 176.01 175.745 175.83 175.78 291982
12/10/2021 9:54 175.895 175.67 175.79 175.695 188332
12/10/2021 9:55 175.705 175.24 175.685 175.375 448620
12/10/2021 9:56 175.38 175.05 175.38 175.155 430128
12/10/2021 9:57 175.4 174.925 175.15 174.925 453117
12/10/2021 9:58 175.001 174.69 174.92 174.775 422128
12/10/2021 9:59 175.21 174.75 174.775 175.18 380997
12/10/2021 10:00 175.51 175.09 175.18 175.45 361698
12/10/2021 10:01 175.63 175.36 175.455 175.42 260332
12/10/2021 10:02 175.49 175.21 175.43 175.36 231188
12/10/2021 10:03 175.54 175.33 175.34 175.533 209592
12/10/2021 10:04 175.57 175.25 175.53 175.4 210473
12/10/2021 10:05 175.588 175.27 175.4 175.51 239867
My desired output >> "Highest Price between 9:30 - 10:00 is 176.556"
CodePudding user response:
This is a slicing operation with multiple conditions. Kindly try:
df = df[(df['date'] >= "12/10/2021 9:30") & (df['date'] <= "12/10/2021 10:00")]['hi'].max()
However you might need to transform the date column to datetime format to properly filter it. This can be done with:
df['date'] = pd.to_datetime(df['date'],infer_datetime_format=True)