【发布时间】:2022-01-11 02:49:04
【问题描述】:
我有一个包含 100 个数据帧的字典,我想每十个数据帧绘制一次。我试过这个,但我有这个错误:
keys = dfs.keys() #keys = dict_keys([1,2,...,100])
# iterate through the dataframe dictionary keys and use enumerate
for idx, key in range(0,len(keys),10): <----------
dfs[key]['Value'].plot(ax=ax_array[idx], title=f'DataFrame: {key}')
plt.tight_layout()
TypeError: cannot unpack non-iterable int object
我知道问题在于 for 循环本身的定义。 但我想绘制:
dfs[1], dfs[10], dfs[20],...,dfs[100]
【问题讨论】:
-
idx, key in range(0,len(keys),10)range 输出单个数字。你期望它解压成两个值 -
keys是dict吗? -
你能说明
keys的定义位置吗
标签: python pandas dataframe dictionary