I have a pandas dataframe that looks like this
data1 data2
0 overall_phase1_b3 overall_phase1_b5
1 overall_phase2_b3 overall_phase5_b5
2 overall_phase3_b3 overall_phase3_b5
My question is how can I get the dataframe rows with matching phase number? If I have phase1 in data1 column, I should have phase1 in data2 column.
Desired Output as below
data1 data2
0 overall_phase1_b3 overall_phase1_b5
1 overall_phase3_b3 overall_phase3_b5