0

I am using pandas in python and I'm have difficulty figuring this out. My data looks like this.

Par   Units   RangeAverage  J_plant  M_plant
pH    pH unit    Range      8.2-8.5  8.1-8.2
pH    pH unit   Average      8.4       8.1
TDS     ppm       Range    284-331   476-598
TDS     ppm     Average      298       575
more rows

I want the data to be pivoted or some other method to get it like below.

Par   Units   J_plant_Range  J_plant_Average  M_plant_Range  M_plant_Average
pH    pH unit    8.2-8.5        8.4             8.1-8.2        8.1
TDS     ppm      284-331        298             476-598        575

Below is a dictionary for your convenience:

plant_dict = {Parameter: [pH, pH, TDS, TDS], Units: [pH unit, pH unit, ppm, ppm], 
RangeAverage: [Range, Average, Range, Average], J_plant: [8.2-8.5, 8.4, 284-331, 298],
M_plant: [8.1-8.2, 8.1, 476-598, 575]}
Shane S
  • 543
  • 3
  • 15
  • improved Dictionary: `plant_dict ={'Parameter': ['pH', 'pH', 'TDS', 'TDS'], 'Units': ['pH unit', 'pH unit', 'ppm', 'ppm'], 'RangeAverage': ['Range', 'Average', 'Range', 'Average'], 'J_plant': ['8.2-8.5', 8.4, '284-331', 298], 'M_plant': ['8.1-8.2', 8.1, '476-598', 575]}` – Shane S Apr 08 '22 at 18:04

0 Answers0