在尝试压平它后,我有一个 pandas 数据框,如下所示:
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
我正在尝试将其保存到数据库中;但是,我在 df.columns 中没有看到符号。为了将 df 保存为以下格式:
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
关于如何实现这一目标有什么建议吗?我的数据库在符号、日期列上有一个复合键。谢谢。
猛跑小猪
相关分类