将 yfinance 数据帧转换为多索引数据帧

时间:2021-07-23 00:23:38

标签: python-3.x pandas dataframe

尝试将此数据帧(df_long)转换为多索引数据帧(df_wide)

从 yfinance 导入此数据。刚接触 Python,所以非常感谢您的帮助 :)

enter image description here

1 个答案:

答案 0 :(得分:0)

要摆脱多索引,请使用 .reset_index():

df_long.pivot_table(index=["Data"], 
                columns='tickers', 
                values='grade').reset_index()

pandas.DataFrame.reset_index