I have a pandas data frame as follows after attempting to flatten it:
df = pd.DataFrame(web.DataReader(stocks, 'yahoo', day, day).iloc[0]).unstack(level=0).droplevel(level=0, axis=1)
Attributes adjClose close ... volume date
Symbols ...
FB 261.399994 261.399994 ... 13587000.0 2020-10-19
AAPL 115.980003 115.980003 ... 120639300.0 2020-10-19
AMZN 3207.209961 3207.209961 ... 5223600.0 2020-10-19
GOOG 1534.609985 1534.609985 ... 1607100.0 2020-10-19
NFLX NaN NaN ... NaN 2020-10-19
I'm trying to persist this to the database; however, I don't see Symbols in the df.columns. In order to save the df to a following format:
Symbols adjClose close ... volume date
FB 261.399994 261.399994 ... 13587000.0 2020-10-19
AAPL 115.980003 115.980003 ... 120639300.0 2020-10-19
AMZN 3207.209961 3207.209961 ... 5223600.0 2020-10-19
GOOG 1534.609985 1534.609985 ... 1607100.0 2020-10-19
NFLX NaN NaN ... NaN 2020-10-19
Any suggestions on how to achieve this? My database has a composite key on Symbols, date columns. Thank You.