擅长:python、mysql、java
<p>3.)</p>
<p>只需再次致电<code>pd.Dataframe()</code>:</p>
<p><code>newdf = pd.Dataframe(df1.City.value_counts())</code></p>
<p>或者</p>
<p><code>newdf = pd.Dataframe(groupby(['City']).size())</code></p>
<p>4.)我认为<code>select distinct</code>euqivalent只会在groupby中使用多个列。例如</p>
<p><code>df1.groupby(['City', 'Name']).size()</code>将返回groupby对象:</p>
<pre><code>City Name
Baires Bob 1
Mallory 1
Caracas Mallory 2
Seattle Alice 1
Bob 1
dtype: int64
</code></pre>