title: Pandas - Conditional Probability of a given specific b
body: <p>I have DataFrame with two columns of "a" and "b".  How can I find the conditional probability of "a" given specific "b"? </p>
  
  <pre><code>df.groupby('a').groupby('b')
  </code></pre>
  
  <p>does not work.  Lets assume I have 3 categories in column a, for each specific on I have 5 categories of b. What I need to do is to find total number of on class of b for each class of a. I tried apply command, but I think I do not know how to use it properly.</p>
  
  <pre><code>df.groupby('a').apply(lambda x: x[x['b']] == '...').count()
  </code></pre>