Python Update Dictionary values to reference dataframes with the same name
<p>I have many dataframes with names such as 'ABC', 'XYZ'...</p>

<p>I also have a dictionary with keys, where each key has a list of 200 values which are the names of the dataframes i.e. ['ABC','XYZ',...]</p>

<p>I want to update this dictionary, so instead of containing the names of the dataframes, it contains the dataframes themselves as a nested dictionary.</p>

<p>THis will enable me to iterate over a specific key of the main dictionary dictionary, and access each of its 200 dataframes  by name</p>

<p>i.e. dictionary[key1][ABC] would print out the ABC dataframe.</p>

<p>Any ideas? :)</p>

<p>What are the keys currently in this dictionary? / Where are your dataframes currently stored? You probably want something like this: </p>

<pre><code>dfDict ={dfName: &lt;df&gt;} #assuming a bit here
newDict = {}
for key, value in oldDict.items():
    newDict[key] = { dfName:dfDict[dfName] for dfName in value }
</code></pre>

python pandas dictionary dataframe nested