I want to create a table of stocks consisting of three columns:
Quantity Day - 1 | Quantity traded | Quantity Day 0
The stocks come in a frame like :
> df
Date Stock Quantity
2019-04-01 ALSC3 19600
AMAR3 3080
2019-04-02 ALSC3 4000
AMAR3 3070
I expected that a simple shift would match the index (Date,StockTicker), but in reality it ignores the index and shifts the row entirely.
Date Stock Quantity Day-1
2019-04-01 ALSC3 3080
AMAR3 4000
2019-04-02 ALSC3 3070
AMAR3 NaN
Does anyone know how to perform it correctly? I would like something like this:
Date Stock Quantity Quantity Day -1
2019-04-01 ALSC3 19600 4000
AMAR3 3080 3070
2019-04-02 ALSC3 4000 NaN
AMAR3 3070 NaN