I want to convert a dataframe with multiple columns to pivot to single row without using any aggregation function. I am using pivot table in pandas after many attempts
dfv = df.pivot_table(index=['Name','Grade'], aggfunc=['min','max'])
but it is failing
Below is the input table
Name Grade Range value1 value2
Pete AT1 100 - 200T 7.8687 31.45
Pete AT1 375 -400T 40.3481 4.53
expected output
Pete Grade min RangeTry min value1 min value2 max RangeTry maxvalue1 maxvalue2
Pete AT1 100 - 200T 7.8687 31.45 375 -400T 40.3481 4.53
problem I am having is when using the min max in aggfunc the values are shuffled at individual column level . I need the shift at the row level..
Pete Grade min RangeTry min value1 min value2 max RangeTry maxvalue1 maxvalue2
Pete AT1 100 - 200T 7.8687 4.53 375 -400T 40.3481 31.45
for example the value 4.53 part of row2 turned out to be part of row 1 group..
Greatly appreciate your help and suggestions