title: Probability of a Pandas value
body: <p>I'm trying to find the probability of a given word within a dataframe, but I'm getting a <code>AttributeError: 'Series' object has no attribute 'columns'</code> error with my current setup. Hoping you can help me find where the error is. </p>
  
  <p>I'm started with a dataframe that looks like the below, and transforming it to find the total count for each individual word with the below function. </p>
  
  <pre><code>query          count
  foo bar        10
  super          8 
  foo            4
  super foo bar  2
  </code></pre>
  
  <p>Function below: </p>
  
  <pre><code>def _words(df):
      return df['query'].str.get_dummies(sep=' ').T.dot(df['count'])
  </code></pre>
  
  <p>Resulting in the below df (note 'foo' is 16 since it appears 16 times in the whole df): </p>
  
  <pre><code>bar      12
  foo      16
  super    10
  </code></pre>
  
  <p>The issue comes in when trying to find the probability of a given keyword within the df, which is currently does not append a column name. Below is what I'm currently working with, but it is throwing the "AttributeError: 'Series' object has no attribute 'columns'" error. </p>
  
  <pre><code>def _probability(df, query):
    return df[query] / df.groupby['count'].sum()
  </code></pre>
  
  <p>My hope is that calling _probability(df, 'foo') will return 0.421052632 (16/(12+16+10)). Thanks in advance! </p>