groupby and add some rows
<p>I have a dataframe below</p>

<pre><code>   A  B
0  a  1
1  a  2
2  c  3
3  c  4
4  e  5
</code></pre>

<p>I would like to get summing result below.key = column A</p>

<pre><code>df.B.groupby(df.A).agg(np.sum)
</code></pre>

<p>But I want to add specific row. </p>

<pre><code>   B
a  3
b  0
c  7
d  0
e  5
f  0
</code></pre>

<p>but I should add row "b" and "d"."f"</p>

<p>How can I get this result ?</p>

<p>Use <code>reindex</code></p>

<pre><code>df.groupby('A').B.sum().reindex(list('abcdef'), fill_value=0)

A
a    3
b    0
c    7
d    0
e    5
f    0
Name: B, dtype: int64
</code></pre>

python pandas