title: Pandas - Get number of elements in already grouped DataFrame
body: <p>I'm trying to get the number of elements in an already grouped DataFrame that was read from a csv-file. The resulting DataFrame can be depicted like so:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>#</th>
  <th>Class A</th>
  <th>Class B</th>
  <th>Class C</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>0</td>
  <td>1</td>
  <td>2,3,4</td>
  <td>5</td>
  </tr>
  <tr>
  <td>1</td>
  <td>2,3</td>
  <td>1</td>
  <td>4,5</td>
  </tr>
  <tr>
  <td>2</td>
  <td>3,5</td>
  <td>1</td>
  <td>2,5</td>
  </tr>
  <tr>
  <td>3</td>
  <td>5</td>
  <td>&quot;1,2,3,4&quot;</td>
  <td></td>
  </tr>
  <tr>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>What I want to achieve is the number of elements in the Classes A, B, C for all rows (concrete values not needed, they are in brackets just for visualization):</p>
  <ul>
  <li>5 occurences of a single element (1, 5, 1, 1, 5)</li>
  <li>4 occurences of two elements (&quot;2,3&quot;, &quot;4,5&quot;, &quot;3,5&quot;, &quot;2,5&quot;)</li>
  <li>1 occurence of three elements (&quot;2,3,4&quot;)</li>
  <li>1 occurence of four elements (&quot;1,2,3,4&quot;)</li>
  </ul>
  <p>I tried this by iterating over each row and column, and by splitting the strings to get the amount of elements, like so:</p>
  <pre><code>for ind in classFrame.index: 
     classes = classFrame['Class A'][ind]
     arr = str(classes).split(&quot;,&quot;)
     print(&quot;len: &quot; + str(len(arr)))
  
     classes = classFrame['Class B'][ind]
     arr = str(classes).split(&quot;,&quot;)
     print(&quot;len: &quot; + str(len(arr)))
  
     classes = classFrame['Class C'][ind]
     arr = str(classes).split(&quot;,&quot;)
     print(&quot;len: &quot; + str(len(arr)))
  </code></pre>
  <p>However, I don't think this is the correct way, and there may be a more elegant solution to my problem.</p>
  <p>Any help highly appreciated!</p>