title: Counting the values in a dataframe column based on user input
body: <p>I'm trying to count the number of occurrences in a column of my dataframe based on the user input:</p>
  <pre class="lang-none prettyprint-override"><code>ID   State        Comments
  1    California   Outsourced
  2    Maryland     NA
  3    Maryland     Outsourced
  </code></pre>
  <p>So, if the user were to enter &quot;Maryland&quot;, Python would return &quot;The number of occurrences in Maryland is 2.&quot; I was having trouble finding answers for this online, so this is how I tried to do it:</p>
  <pre><code>state_input = input(&quot;Enter the state: &quot;)
  while True:
      if state_input == df['State']:
         df['State'].eq(state_input).sum()
      break
  if cases &gt; 0:
      print(cases)
  </code></pre>