1

I am trying to find a solution to pivot data in Pandas in the same manner with which I pivot it in Spotfire but am coming up short with respect to how to accomplish this.

enter image description here

Here is the basis for the dataframe

lot_id      run wafer   x   y   test_number test_name   value
RBC45627    304102  550000  -120    -2  4   Test1                   1.0
RBC45627    304102  550000  -120    -2  11  Test2                   1.0
RBC45627    304102  550000  -120    -2  200 Test3                   9.35e-07
RBC45627    304102  550000  -120    -2  204 Test4                   1.16e-06
RBC45627    304102  550000  -120    -2  206 Test5                   -2.83e-09
RBC45627    304102  550000  -120    -2  210 Test6                   -1.32e-09
RBC45627    304102  550000  -120    -2  700 Test7                   1.21e-11

it then gets pivoted to a single row based on the uniqueness of the columns (lot_id, run, wafer, x, y) and 7 new columns were created based on the concatenation of test_number + test_name

lot_id   wafer   x   y   11.Test2   200.Test3   204.Test4   206.Test5   210.Test6   4.Test1   700.Test7
RBC45627, 304102, 550000, -120, -2, 1, 9.35E-07, 1.16E-06, -2.83E-09, -1.32E-09, 1, 1.21E-11

My attempts have lead to nowhere with the closest being using the following but this leaves me without the original columns that are desired.

fromCSV.pivot(columns=['test_number'],values='value',index=['x','y'])
Nick
  • 138,499
  • 22
  • 57
  • 95

0 Answers0