How can I plot my groupby() result?
<p>I'm running a <code>groupby()</code> on my data like this:</p>

<pre><code>user.groupby(["DOC_ACC_DT", "DOC_ACTV_CD"]).agg("sum")["SUM_DOC_CNT"]
</code></pre>

<p>which results in this grouped data:</p>

<pre><code>DOC_ACC_DT  DOC_ACTV_CD
2015-07-01  BR              1
            PT              1
2015-07-02  BR              1
            PT              1
2015-07-06  BR              1
            PT              1
2015-07-08  BR              1
2015-07-09  AD              2
            PT              1
2015-07-13  AD             50
            BR             52
            PT              1
2015-07-14  AD              6
            BR              5
            PT              1
2015-07-16  BR              1
            PT              1
2015-07-23  AD             13
            BR             14
            PT              3
2015-07-27  BR              1
            PT              1
</code></pre>

<p>What I want to do now is simply plot by <code>DOC_ACTV_CD</code>. Please not that there are gaps between days so I'd have to fill in zero-values between days where nothing happened e.g.</p>

<pre><code>2015-07-23  AD             13
            BR             14
            PT              3
2015-07-25  BR              1
            PT              1
</code></pre>

<p>would have to become</p>

<pre><code>2015-07-23  AD             13
            BR             14
            PT              3
2015-07-24  AD              0
            BR              0
            PT              0
2015-07-25  AD              0
            BR              1
            PT              1
</code></pre>

<p>before I plot a time series for <code>AD</code>, <code>BR</code> and <code>PT</code> in one plot. What's the quickest way to do this?</p>

<p>You can use:</p>

<pre><code>df = user.groupby(["DOC_ACC_DT", "DOC_ACTV_CD"]).agg("sum")["SUM_DOC_CNT"]
df.unstack().resample('D').replace(np.nan,0).plot()
</code></pre>

python pandas plot resampling