回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我使用的是python2.7。我有一个熊猫数据框,看起来像</p>
<pre><code>raw_data = {'Date': ['12/1/2016', '12/4/2016','12/23/2016', '1/18/2017','1/18/2017','1/19/2017'],
'Account': ['aa1', 'aa2','aa1', 'aa1', 'aa1', 'aa2'],
'Description': ['store1', 'store2','store1', 'store2','store1','store2' ],
'Amount': [26.43, 24.99, 31.54,45.32, 2.00, 15.41],
'Category': ['G','G','G','G','G','G'],
'Initials': ['FR','DB','FR','DB','FR','FR']}
df = pd.DataFrame(raw_data, columns = ['Date','Account','Description','Amount','Category','Initials'])
</code></pre>
<p>我想按每个描述和月份进行汇总,这样我的数据看起来是:<br/>
日期说明金额<br/>
2016年12月store1 57.97<br/>
2016年12月store2 24.99<br/>
2017年1月store1 2.00<br/>
2017年1月store2 60.73<br/></p>
<p>我已经写了下面的代码,每个月的总和,但我坚持如何合并描述列。在</p>
^{pr2}$
<p>任何指导都将不胜感激。谢谢。在</p>