how to sum complicated condition in pandas dataframe
<p>I have dataframe below;</p>

<pre><code>df=pd.DataFrame(np.arange(1,19).reshape(6,3),columns=list('ABC'),index=list('acbabc'))

    A   B   C
a   1   2   3
c   4   5   6
b   7   8   9
a  10  11  12
b  13  14  15
c  16  17  18
</code></pre>

<p>I would like to conditional summing dataframe shown as below;</p>

<pre><code>   A  B  C
a 11 13 15
b 20 22 24
c 20 22 24
</code></pre>

<p>each elements shows conditional sum of df.for instance,(I am inconfident about expression)           </p>

<pre><code>result.loc[0,0]=df.loc[df.A=="a"].sum() 
</code></pre>

<p>how can I get this dataframe ?</p>

<p>Groupby <code>index</code> and <code>sum</code> the columns should give you what you need:</p>

<pre><code>df.groupby(df.index).sum()

#    A   B   C
#a  11  13  15
#b  20  22  24
#c  20  22  24
</code></pre>

python pandas numpy dataframe