0

I’m trying to create data frame with pandas from this query data = cur.execute(CREATE TABLE Stocks (date DATE, price NUMERIC, ticker VARCHAR (5) NOT NULL, name VARCHAR (1000))).fetchall()

for regular parse of list of dictionaries to DataFrame df = pd.DataFrame(data) output looks like this:

27/12/2019  53.46   ORCL    ORACLE CORP
30/12/2019  52.7    ORCL    ORACLE CORP
31/12/2019  52.98   ORCL    ORACLE CORP
02/01/2009  20.33   MSFT    MICROSOFT CORP
05/01/2009  20.52   MSFT    MICROSOFT CORP
06/01/2009  20.76   MSFT    MICROSOFT CORP

So there are data sorted by ticker and then by date. How can I create table indexed by date where name of column will be ticker, like that:

           ORCL    MSFT
26/12/2019  52.4   150
27/12/2019  52.46  150.1
30/12/2019  52.7   150

dates are the same for all tickers

0 Answers0