【问题标题】:Dataframe index is not set properly in pandas/quandl在 pandas/quandl 中未正确设置数据框索引
【发布时间】:2020-03-24 15:25:00
【问题描述】:
import pandas as pd
import quandl
df = pd.DataFrame(quandl.get('WIKI/GOOGL'))
print(df.head())

当我从 Quandl 导入数据时,这就是导入数据的方式,如图所示。

但我不希望日期成为索引,相反,我希望索引是正常的数字,例如 0、1.... 等等

【问题讨论】:

    标签: python pandas quandl


    【解决方案1】:

    你可能想试试这个。

    df.reset_index(inplace=True)
    

    【讨论】:

    • hhhmm 很有趣,我复制了你的代码,它成功了,你确定吗?尝试添加inplace=True
    猜你喜欢
    • 2021-12-31
    • 2018-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-22
    • 2020-06-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多