Pandas Groupby: Count and mean combined : <p>Working with PANDAS to try and summarise a dataframe as a count of certain categories, as well as the means sentiment score for these categories.</p>

<p>There is table full of strings which have different sentiment scores, and I want to group each text source by saying how many posts they have, as well as the average sentiment of these posts.</p>

<p>My (simplified) dataframe looks like this:</p>

<pre><code>source    text              sent
--------------------------------
bar       some string       0.13
foo       alt string        -0.8
bar       another str       0.7
foo       some text         -0.2
foo       more text         -0.5
</code></pre>

<p>The output from this should be something like this:</p>

<pre><code>source    count     mean_sent
-----------------------------
foo       3         -0.5
bar       2         0.415
</code></pre>

<p>The answer is somewhere along the lines of:</p>

<pre><code>df['sent'].groupby(df['source']).mean()
</code></pre>

<p>Yet only gives each source and it's mean, with no column headers.</p>

<p>Thanks in advance!</p>
