I have created a mock dataset based on your example:
import pandas as pd
import numpy as np
df = pd.DataFrame({
"ID": ["1", "1", "2", "3", "3", "3"],
"Data 1": ["data11", "data11", "data12", "data13", "data13", "data13"],
"Data 2": ["data21", "data21", "data22", "data23", "data23", "data23"],
"Design Code": ["a", "b", "c", "d", "e", "f"]
})
You can apply different aggregations to different columns in groupby to achieve the expected results, for example:
df \
.groupby("ID", as_index=False) \
.agg({
"Data 1": min,
"Data 2": min,
"Design Code": lambda x: "\n".join(np.unique(x)),
})
Output:
ID Data 1 Data 2 Design Code
0 1 data11 data21 a\nb
1 2 data12 data22 c
2 3 data13 data23 d\ne\nf
As for the displaying of Design Code
with line breaks you can refer to https://stackoverflow.com/a/46326725/22052558 if you are using jupyter notebook.