Count number of occurrence in a column Python
<p>I want to count the number of occurrences for each input in the column Echantillon. For example:</p>

<pre class="lang-none prettyprint-override"><code>Echantillon   Classe
1001            0
956             1
9658            2
1001            0
8566            2
956             1
</code></pre>

<p>How can this be done using Python?</p>

<p>If I understand properly then you want total numbers by classes. If it so then you can do it by:</p>

<pre><code>In [9]: df
Out[9]: 
   Echantillon  Classe
0         1001       0
1          956       1
2         9658       2
3         1001       0
4         8566       2
5          956       1
</code></pre>

<p>then you can use groupby function:</p>

<pre><code>In [10]: df.groupby(df['Classe']).sum()
Out[10]: 
        Echantillon
Classe             
0              2002
1              1912
2             18224
</code></pre>

python pandas