【问题标题】:Retrieving/referencing information within dataframes contained in dictionaries在字典中包含的数据框中检索/引用信息
【发布时间】:2020-02-01 14:30:10
【问题描述】:

我创建了一个字典,其中包含存储来自 11 个不同模拟的数据的数据帧。我现在需要从每个帧中提取数据来执行我的分析。

x=np.arange(0,11)

df_stiff={}

for i in x:

    name='df_stiff' + str(i)

    df_stiff[name]=pd.DataFrame()

但是,每当我尝试从日期框架中检索/提取信息时,我都无法这样做。

我曾尝试使用语法 df_stiff[df_stiff0] 等...但是,我不断收到 df_stiff0 未定义的错误(尽管它是键值和字典中数据框之一的标题)。谁能帮我语法?

【问题讨论】:

    标签: python python-3.x dataframe dictionary data-retrieval


    【解决方案1】:

    您只是缺少引号 - 使用 df_stiff['df_stiff0']。现在您正尝试使用确实未定义的变量 df_stiff0 进行索引。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-03
      • 2018-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-03
      • 1970-01-01
      相关资源
      最近更新 更多