0

I have a dataframe with 3 columns. The first is a date, second is a product name, and third is a price. Currently set up as follows- Original Table Image | Date | Prod_name | Price | |------|-----------|-------| | 1 | A | $1 | | 2 | A | $2 | | 3 | A | $3 | | 1 | B | $5 | | 2 | B | $10 | | 3 | B | $15 | | 1 | C | $8 | | 2 | C | $8 | | 3 | C | $8 |

But it needs to be formatted differently for upload requirements. WHat is the best way to have the unique product names as columns, unique dates as rows, and prices as cell values? THe example above would become- Formatted Table |Date|A|B|C| | --- | --- | --- | --- | |1 |$1|$5|$8| |2 |$2|$10|$8| |3 |$3|$15|$8|

I could loop through the table and set values in each cell by looking up the product name, date pair in the original table, but wondering if pandas has some short cut way of doing this?

norewiler
  • 1
  • 1

0 Answers0