I have a dataframe that looks like this:
CURRENT DATAFRAME
Branch ID | Dispense Type | Product ID | Date | Quantity
-------------------------------------------------------------
A | Shipped Out | ABC3 | 5/6/19 | 10
A | Received | ABC3 | 5/6/19 | 8
A | Transferred | ABC3 | 5/6/19 | 0
A | Shipped Out | ABC3 | 5/7/19 | 5
A | Received | ABC3 | 5/7/19 | 7
A | Transferred | ABC3 | 5/7/19 | 20
B | Shipped Out | ABC3 | 5/6/19 | 40
B | Received | ABC3 | 5/6/19 | 0
B | Transferred | ABC3 | 5/6/19 | 1
B | Shipped Out | ABC3 | 5/7/19 | 6
B | Received | ABC3 | 5/7/19 | 2
B | Transferred | ABC3 | 5/7/19 | 3
A | Shipped Out | QRE3 | 5/6/19 | 7
A | Transferred | QRE3 | 5/6/19 | 10
A | Received | QRE3 | 5/6/19 | 5
(The spaces between the rows are included here just so that the dataframe is clear and makes sense, I don't need spaces in the actual dataframe generated in my code.)
Ideally, the Dataframe I would like as an end-result would use the column "Dispense Type" to make additional columns, and reduce the number of rows as a result.
DESIRED RESULT DATAFRAME
Branch ID | Date | Product ID | Shipped Out | Received | Transferred
------------------------------------------------------------------------
A | 5/6/19 | ABC3 | 10 | 8 | 0
A | 5/7/19 | ABC3 | 5 | 7 | 20
B | 5/6/19 | ABC3 | 40 | 0 | 1
B | 5/7/19 | ABC3 | 6 | 2 | 3
A | 5/6/19 | QRE3 | 7 | 10 | 5
One Branch can ship two different products, which explains why there are two different A blocks (with different Product IDs) in the original and result dataframes.
I tried to use Pivot table, but what happens is that when one column, 'Shipped Out' has a value, the other two columns will have the value NaN. So there's only one column that will have a value while the other two will be filled with Nulls.
Note: I understand that this is similar to the "how to pivot a dataframe" question, but after reading it, and trying certain methods, I have only run into errors and am not sure what tactic would work.