pivot table not transposing row values into columns

Viewed 15

I'm having trouble generating a pivot table. The code runs but the output is wrong. The pivot table is not transposing the target column values as unique columns.

This image is the output of the pivot table. It is wrong. I want the Symbol column eliminated and the underlying values to be a unique column.

I want to transpose the Symbol column values as individual columns in pivot table

This is how I created the pivot table. I am using a concatenated dataframe of different data sources that have the same format, I removed the date index column, ran pivot_table() indicating the 'Symbol' column

combined_df = pd.concat([amd, mu], axis='rows', join='inner')
combined_df = combined_df.reset_index() # remove the index
combined_df.pivot_table(values='NOCP', index='Trade DATE', columns='Symbol')
combined_df.head()

The output should look like this, values being a unique column:

Correct pivot table

0 Answers
Related