擅长:python、mysql、java
<p>如有必要,在列中添加<a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.unstack.html" rel="nofollow noreferrer">^{<cd1>}</a>和<a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.reset_index.html" rel="nofollow noreferrer">^{<cd2>}</a><code>ID</code>:</p>
<pre><code>df = gp1.groupby(by=['ID', 'CD'])['BALANCE_AM'].sum().unstack().reset_index()
</code></pre>