I have a df as below
Astrt Aend Bstrt Bend Xstrt Xend Ystrt Yend
25 27 15 16 11 12 40 42
50 51 45 46 23 25 35 36
14 15 21 20 8 9 2 3
11 11 45 49 46 47 12 13
In this df, columns starting with A are linked with columns starting with X and columns starting with B are linked with columns starting with Y.
What I want is
- Identify the largest of ALL columns that has `strt', that is Astrt,Bstrt,Xstrt & Ystrt and put in a new column 'Tsrt'
- Then the corresponding 'end' value in anew column 'Tend'. So, for example if is 'Bstrt' is the biggest, then 'Bend' (does not matter if it is biggest or not) goes into column 'Tend'
- As I said, columns starting with
Aare linked with columns starting withXand columns starting withBare linked with columns starting withY. So the 2 new columns 'Ustrt' & 'Uend' should be filled with start & end values of respective columns For ex, if 'Xstrt' is the biggest, then 'Ustrt' & 'Uend' column will have values from 'Astrt' & 'Aend' (no analysis needed, just directly the values).
So basically, we need to find the max of ALL columns that has `strt', identify the name of that & copy values based on its relationship.
The expected out of the df above is as below.
Astrt Aend Bstrt Bend Xstrt Xend Ystrt Yend Tstrt Tend Ustrt Uend
25 27 15 16 11 12 40 42 40 42 15 16
50 51 45 46 23 25 35 36 50 51 23 25
14 15 21 20 8 9 2 3 21 20 2 3
11 11 45 49 46 47 12 13 46 47 11 11
Hopefully, it is clear what i am trying to do. Can someone help? Thanks.