擅长:python、mysql、java
<p>你可以这样做:</p>
<pre><code>Data.groupby(by="Major Brand")["2016 Units","2015 Units"].sum()
</code></pre>
<p>演示:</p>
^{pr2}$
<p>数据:</p>
<pre><code>In [30]: Data
Out[30]:
Major Brand 2016 Units 2015 Units X
0 1 75 83 xxx
1 1 82 95 xxx
2 3 85 47 xxx
3 3 1 40 xxx
4 1 43 43 xxx
5 4 35 65 xxx
6 3 38 71 xxx
7 4 56 90 xxx
8 3 9 77 xxx
9 1 18 17 xxx
10 3 59 38 xxx
11 4 85 17 xxx
12 2 64 13 xxx
13 2 32 33 xxx
14 2 76 76 xxx
</code></pre>