0

In the column "Test_method", there are three types, including FT, TZ and MM. I want to subtract the rows under FT and TZ by the rows under MM corresponding to the same Name. The sample of the dataset is shown in the image.

samples

import pandas as pd
df = pd.DataFrame({'Name' : ['CYH','CYH','CYH', 'DMH','DMH','DMH'],
                   'Test_method' : ['FT','FT','MM','FT','FT','MM'],
                   'Neck_cir' : [35.42, 35.48, 30.5, 37.04, 37.84, 36],
                   'Chest_cir' : [86.15, 86.75, 87, 83.11, 83.42, 85]})

output

| Name | Test_method | Neck_cir | Chest_cir |
|------|-------------|----------|-----------|
| CYH  | FT          | 4.92     | -0.85     |
| CYH  | FT          | 4.98     | -0.25     |
| DMH  | FT          | 1.04     | -1.89     |
| DMH  | FT          | 1.84     | -1.58     |
Brian Luo
  • 1
  • 1

0 Answers0