绘制 DataFrame 字典

Pil*_*lik 6 python dictionary matplotlib pandas

我有一个dictionaryDataFrames,我要使用的图形。这是数据的示例:

import pandas as pd
import numpy as np

np.random.seed(5)
first = pd.DataFrame(columns=range(1,4),data=np.random.rand(3,3), index=range(1,4))
second = pd.DataFrame(columns=range(1,4),data=np.random.rand(3,3)+0.2, index=range(1,4))
third = pd.DataFrame(columns=range(1,4),data=np.random.rand(3,3)+0.05, index=range(1,4))
fourth= pd.DataFrame(columns=range(1,4),data=np.random.rand(3,3)-0.2, index=range(1,4))

d={'frame_1':first,'frame_2':second,'frame_3':third,'frame_4':fourth}

#This is what it looks like
d
    {'frame_1':           1         2         3
 1  0.221993  0.870732  0.206719
 2  0.918611  0.488411  0.611744
 3  0.765908  0.518418  0.296801, 'frame_2':           1         2         3
 1  0.387721  0.280741  0.938440
 2  0.641309  0.358310  1.079937
 3  0.474086  0.614235  0.496080, 'frame_3':           1         2         3
 1  0.678788  0.629838  0.649929
 2  0.315819  0.334686  0.303588
 3  0.377564  0.194164  0.215613, 'frame_4':           1         2         3
 1  0.763931  0.760227 -0.011585
 2 -0.175693  0.004556  0.499844
 3  0.579515 -0.177067  0.377663}
Run Code Online (Sandbox Code Playgroud)

最终,我想要 9 个单独的图,它们将DataFrame(11,12,13,..)中每个元素组合的演变与 1,2,3,4(与“frame_1”、“frame_2”等相关)绘制为x 轴。明确地说,这意味着第一个图(与 11 相关)应包含值 0.221993、0.387721、0.678788 和 0.763931。

通常我总是解释我自己试图解决的问题。但是,在这种情况下,我对可能的解决方案一无所知。

注意:实际数据集是 10x10DataFrames并且dictionary包含 75 个这样的数据帧,所以我希望尽可能多的自动化。

R. *_*Cox 1

我不确定我是否明白你想要什么结果,但是:

for k in d:
    ax = d[k].plot()
Run Code Online (Sandbox Code Playgroud)

给出:

在此输入图像描述 在此输入图像描述 在此输入图像描述