Append dataframe to dict
<p>I've created a dict of dicts structured in such a way that the key is the department ('ABC') then the date (01.08) is the key and values are { product name (A), Units (0), Revenue (0)}. This structure continues for several departments. See dict of dict printout below. </p>

<pre><code>'ABC':                                                                   01.08  \


A.         Units           0
                                          Revenue               0
B.         Units           0
                                          Revenue               0
C.         Units           0
                                          Revenue               0
D.         Units           0
                                          Revenue               0
</code></pre>

<p>Additionally, I've created a dataframe using groupby and an aggregation function (sum) to get the total of units and revenue per day per department (this is an aggregation of two levels as opposed to three in the dict - date , department, product).</p>

<p>Printing out df, which is an aggregation of number of units and total revenue, results in:                                               </p>

<pre><code>print df.ix['ABC']

                        Total Overall Units  \
dates
2016-08-01                   2
2016-08-02                   0
2016-08-03                   2
2016-08-04                   1
2016-08-22                   2

                       Total Overall Revenue \
dates
2016-08-01              20
2016-08-02              500
2016-08-03              39
2016-08-04              50
</code></pre>

<p>I am currently ending up with two separate objects which I want to merge/append such that the total units and total revenue will be added to the end of the dict in the correct place (i.e. mapped to the correct department and date).
Currently I am printing the dict and then the dataframe <code>pd.to html</code> separately by 'department' so I am left with two separate tables. Not only are they separate even but the table created from the df also has one fewer column as they are grouped differently.</p>

<pre><code>'ABC':
                         01.08  |  02.08  |   03.08  |   04.08
A       Total Units        0         0          0          0
        Total Revenue      0         0          0          0
B       Total Units        0         0          0          0
        Total Revenue      0         0          0          0 
C       Total Units        0         0          0          0
        Total Revenue      0         0          0          0
D       Total Units        0         0          0          0
        Total Revenue      0         0          0          0
     Total Overall Units   0         0          0          0
     Total Overall Revenue 0         0          0          0
</code></pre>

<ol>
<li>Can I add the dataframe to the dict by 'department name'?</li>
<li>Ultimate goal is to merge these two data objects into one unified data object or to literally align the objects for readability.</li>
</ol>

<p>Any ideas?  </p>

<p>Skipping to question #2: I'd recommend using a single dataframe to store all of your information. It will be much easier to work with than keeping columnar data in a dict of dicts. Set the date as the main index and either use a separate column for each field ('deptA-revenue') or use multi-indexing. You can then store the daily totals as columns in the same dataframe.</p>

python pandas dictionary