I have a df:
Field Value Name Fred Age 69 Gender M I want to use the values in 'Field' as the new dataframe column headers to have a df shaped like so:
Name Age Gender Fred 69 M Right now I call
df.pivot(columns='Field', values='Value') but that leaves me with a dataframe of multiple rows containing all NaN values except for one value for that specific row (such as Name).
df.set_index('Field').Tfits the bar for this example. can you include a couple more rows/columns so we understand what's actually happening in the reshape? I assume you don't just have a single 1:1 mapping between Field and Value?