Getting previous week low corresponding to the highest high of previous week, in pandas dataframe using 30 min data

I have a few set of data where the index is based on 30min data from monday to friday. There might some missing dates (Might be because of holidays).

Below are the desired output

  1. Looking for last week (ie from 11th july 22 to 15th july 22) and get the low related to the 30min highest high. which occurred on 12-07-2022 09:15:00
  2. A new column which populates all the low for last week(30 min interval) with the values 369.2 (green in color) for this week and 370.05(Orange in color) for last week (Whose value is derived as low of the 30min highest high of week 4th july to 8th july)
  3. there might be missing dates (because of data unavailable) but still for the whole last week 30 min highest high is 376.25 and its corresponding low is 369.2 which needs to be populated for the this df[“Previous week corresponding low of the 30min highest high”]

How far have you got in solving your problem? Which difficulties have you encountered? What would you like to ask the others to help with?

Note: In this case the picture is OK for illustration (it highlights the interesting values) but put your program and any testing data as a text here.

I just converted the below data set into a dataframe. After not getting how to get to result , what should be done. Basically i am new to python(just 1 month).

Below is the data set to test. datetime is the index. I used df.reset_index(inplace=True) for converting the datetime index as a column.

datetime high low
07-07-2022 09:15 377.5 366.5
07-07-2022 09:45 376.45 374.2
07-07-2022 10:15 375 372.6
07-07-2022 10:45 374.75 372.15
07-07-2022 11:15 374.25 372.2
07-07-2022 11:45 374.45 373.1
07-07-2022 12:15 373.6 372.4
07-07-2022 12:45 373.2 371.1
07-07-2022 13:15 373.15 371.3
07-07-2022 13:45 373.25 370.75
07-07-2022 14:15 373.95 370.55
07-07-2022 14:45 373.55 372.5
07-07-2022 15:15 372.6 371.7
08-07-2022 09:15 374.9 369.25
08-07-2022 09:45 370 369
08-07-2022 10:15 370.3 369.2
08-07-2022 10:45 370 369.05
08-07-2022 11:15 370 369.15
08-07-2022 11:45 369.95 367.8
08-07-2022 12:15 369.8 368.3
08-07-2022 12:45 369.3 367.65
08-07-2022 13:15 368.5 367.2
08-07-2022 13:45 368.3 365.6
08-07-2022 14:15 367.6 365.55
08-07-2022 14:45 371.35 366.95
08-07-2022 15:15 372 370.05
11-07-2022 09:15 370.85 368.05
11-07-2022 09:45 370.6 369.05
11-07-2022 10:15 370 368.85
11-07-2022 10:45 369.85 367.4
11-07-2022 11:15 368.9 367.6
11-07-2022 11:45 368.4 367.65
11-07-2022 12:15 368.5 367.7
11-07-2022 12:45 370 368.05
11-07-2022 13:15 370 368.5
11-07-2022 13:45 370.1 369.2
11-07-2022 14:15 371.4 368.8
11-07-2022 14:45 371.5 369.35
11-07-2022 15:15 371.7 370
12-07-2022 09:15 376.25 369.2
12-07-2022 09:45 375.55 374.15
12-07-2022 10:15 375.45 373.3
12-07-2022 10:45 374.95 373.35
12-07-2022 11:15 375 371.1
12-07-2022 11:45 371.75 370.05
12-07-2022 12:15 370.15 368.6
12-07-2022 12:45 369.95 369.15
12-07-2022 13:15 370 366.7
12-07-2022 13:45 369.15 366.65
13-07-2022 11:15 368.35 365.85
13-07-2022 11:45 370 367.9
13-07-2022 12:15 369.45 367.65
13-07-2022 12:45 367.85 365.1
13-07-2022 13:15 366.9 365.4
13-07-2022 13:45 368.5 366
13-07-2022 14:15 368.4 366.05
13-07-2022 14:45 366.65 364.5
13-07-2022 15:15 366.35 364.55
14-07-2022 09:15 368.15 364.4
14-07-2022 09:45 366.55 364.85
14-07-2022 10:15 365.15 363.25
14-07-2022 10:45 365.25 363.55
14-07-2022 11:15 365.15 363.55
14-07-2022 11:45 365.3 362.1
14-07-2022 12:15 364 362.5
14-07-2022 12:45 364.5 363.05
14-07-2022 13:15 364.25 363.05
14-07-2022 13:45 364.7 362.5
14-07-2022 14:15 364.2 362.75
14-07-2022 14:45 366.45 363.2
14-07-2022 15:15 367.1 365.6
15-07-2022 09:15 369.5 366.35
15-07-2022 09:45 368.8 367.15
15-07-2022 10:15 368.85 367.2
15-07-2022 10:45 367.5 365.2
15-07-2022 11:15 367.25 366.2
15-07-2022 11:45 367.4 365.5
15-07-2022 12:15 366.25 364.45
15-07-2022 12:45 366.8 365.25
15-07-2022 13:15 366.2 365.05
15-07-2022 13:45 366.25 365.15
15-07-2022 14:15 367.45 365.85
15-07-2022 14:45 368.5 366.75
15-07-2022 15:15 368.8 367.45
18-07-2022 09:15 371.4 367.7
18-07-2022 09:45 372.3 370
18-07-2022 10:15 372.35 370.9
18-07-2022 10:45 373.3 371.35
18-07-2022 11:15 373.2 371.7
18-07-2022 11:45 374.8 372.55
18-07-2022 12:15 374.7 373.35
18-07-2022 12:45 375 373.7
18-07-2022 13:15 374.7 373.7
18-07-2022 13:45 375 373.6
18-07-2022 14:15 375 373.6
18-07-2022 14:45 375.45 374.05
18-07-2022 15:15 376 374.45

@ragsfdc, posting your data as data (text) is much appreciated. Please fence it with triple backticks (top left on U.S. keyboard) so it appears in a scrollable frame:

```
<data here>
```

That also adds other benefits like a ‘copy’ function button. :smiley:

If what you’re asking is to get df["low"] at the row for which df["high"] is the maximum, then it is quite streightforward with Pandas. First, you need to get the row index of the maximum value of the "high" column, which you can do with the df.idxmax method. Then, just get the row of the "low" column if

Also, did you try simply searching for the problem? As a beginner, someone else has already solved almost anything you might be asking already, and searching is a critical important skill for a programming, not to mention both quicker for you and for us. The very first result for get row with max value in data frame seemed quite helpful.

Best of luck!