i am not sure if, and how i can do the following transformation:
I have a DataFrame looking like this:
Index Name detail1 detail1_value detail2 detail2_value detail3 detail3_value
1 Albert Age 30 Group A Hometown beautifulplace
2 Bea Age 28 Hometown anotherplace None None
3 Celin Age 45 Group B None None
4 Dave Group A None None None None
But as you can imagine, my aim is:
Index Name Age Group Hometown
1 Albert 30 A beautifulplace
2 Bea 28 anotherplace
3 Celin 45 B
4 Dave A
I am pretty sure that ech detail just appears once. To keep things complex: i am not sure if every detail is total identical (in some cases for example Hometowns instead of Hometown).
The only solution i can see so far is to produce singel pivot-tables out of each pair of columns (like detail1 and detail1_value). In a second step an new dataset is created and each of these pivot-tables is searched for example on the Information on the Age. But my trust in python tells me, that there must be a better way...
Thanks!
PS: May help:
dataset = pd.DataFrame({'Name': ['Albert', 'Bea', 'Celine', 'Dave'],
'detail1': ['Age', 'Age', 'Age', 'Group'],
'detail1_value': ['30', '28', '45', 'A'],
'detail2': ['Group', 'Hometown', 'Group', None],
'detail2_value': ['A', 'anotherplace', 'B', None],
'detail3': ['Hometown', None, None, None],
'detail3_value': ['beautifulplace', None, None, None]})