Assuming I have the dataset
ID cond press metrics
0 h1 new 30 1.2
1 h2 old 30 1.0
2 h3 new 50 1.5
3 h4 old 50 1.4
4 h5 new 70 1.8
I want to add another column called ratios, which is the ratio between the same ID & press with cond old/new. If pairs not found, fill the value with zero.
The final results will be:
ID cond press metrics ratios
0 h1 new 30 1.2 1.0/1.2
1 h2 old 30 1.0 0
2 h3 new 50 1.5 1.4/1.5
3 h4 old 50 1.4 0
4 h5 new 70 1.8 0