I have one Pandas dataframe that contains information thus:
index year month day symbol transaction nr_shares
2011-01-10 2011 1 10 AAPL Buy 1500
2011-01-13 2011 1 13 GOOG Sell 1000
and I would like to fill a second, zero-filled Pandas dataframe
index AAPL GOOG
2011-01-10 0 0
2011-01-11 0 0
2011-01-12 0 0
2011-01-13 0 0
using the information from the first dataframe so I get
index AAPL GOOG
2011-01-10 1500 0
2011-01-11 0 0
2011-01-12 0 0
2011-01-13 0 -1000
where it can be seen that on the relevant dates the buy and sell transactions for a specified number of shares have been entered in the appropriate column, with a positive number for a buy and a negative number for a sell order.
How can I accomplish this? Will I have to loop over the first dataframe index and check the symbol and transaction columns using nested "if" statements and then write to the second dataframe, or is there a more elegant dataframe method that I could use?