Pandas Mean for Certain Column
<p>I have a pandas dataframe like that:</p>

<p><a href="http://i.stack.imgur.com/KOZan.png" rel="nofollow"><img src="http://i.stack.imgur.com/KOZan.png" alt="enter image description here"></a></p>

<p>How can I able to calculate mean (min/max, median) for specific column if Cluster==1 or CLuster==2?</p>

<p>Thanks!</p>

<p>You can create new df with only the relevant rows, using:</p>

<pre><code>newdf = df[df['cluster'].isin([1,2)]

newdf.mean(axis=1)
</code></pre>

<p>In order to calc mean of a specfic column you can:</p>

<pre><code>newdf["page"].mean(axis=1) 
</code></pre>

python pandas numpy