擅长:python、mysql、java
<p>使用来自<code>pd.groupby</code>的石斑鱼-</p>
<pre><code>df1, df2, df3 = [i[1] for i in df.groupby(['ID'])]
</code></pre>
<p>使用带有<code>pd.Series.unique</code>的条件-</p>
<pre><code>df1, df2, df3 = [df[df['ID']==i] for i in df['ID'].unique()]
</code></pre>
<p>每种方法的输出-</p>
<pre><code>df1
ID State Invoice Price Email
0 1000 Texas 1 2 texas@test.com
1 1000 Texas 2 5 texas@test.com
3 1000 Texas 4 8 texas@test.com
#df2
ID State Invoice Price Email
2 1001 Alabama 3 4 alabama@test.com
5 1001 Alabama 6 6 alabama@test.com
#df3
ID State Invoice Price Email
4 1002 Georgia 5 3 georgia@test.com
</code></pre>