0

I have a very old piece of software in my lab that only takes input in a format as

product1, test1, test2, test3
product2, test1, test4

so the software knows to apply test1/2/3 on product 1 and test1/4 on product2.

Now I have collected much new information in a long format like:

import pandas as pd

D = pd.DataFrame({
    'Product':['A', 'A', 'A', 'B', 'B'],
    'Test': ['t1', 't2', 't3', 't3', 't4'],
})

print(D)

  Product Test
0       A   t1
1       A   t2
2       A   t3
3       B   t3
4       B   t4

Is there any way to convert the table to

A, t1, t2, t3
B, t3, t4

It does not really have to a dataframe. Some plain text is pretty OK to copy and paste already.

John
  • 1,647
  • 1
  • 20
  • 46

0 Answers0