title: Pulling a specific value from a Pandas GroupBy Object
body: <p>Running Python 3.6.4, pandas 0.22 and numpy 1.14.1</p>
  
  <p>I am looking to pull a specific value from a Pandas <code>GroupBy object</code>.</p>
  
  <p>I am taking my initial dataset, opening into a <code>dataframe</code> filtering out unnecessary columns. Then I am doing a <code>groupby</code>, where Columns D, E, F, G and H are each summed based on columns A, B and C. This gives me the data-set that I need to pull values from.</p>
  
  <p>First here's an example of the type of group by I am using. (Maybe this can be corrected)</p>
  
  <pre><code>output = df.groupby(['A', 'B', 'C'], as_index=False).agg({'D': [np.sum], 'E': [np.sum],'F': [np.sum],'G': [np.sum],'H': [np.sum]})
  </code></pre>
  
  <p>If it helps, Columns A, B and C are all strings, where D through H are all converted to numbers using the <code>to_numeric</code> method.</p>
  
  <p>Next, I am looking to pull a specific value out of this new data-set using the maximum value of Column A.</p>
  
  <p>I can pull a series using loc, but I want to pull the value of a certain position and then insert that into another dataframe. Maybe loc does this, I just want to be certain that whatever I pull from this group by object, gets put into the new <code>dataframe</code>. So is the value is 4, I get a variable = 4, and then can put that into another <code>dataframe</code>.</p>
  
  <pre><code>value = output.at[output.A.idxmax(), 'D']
  </code></pre>
  
  <p>The error I am getting is <code>TypeError: only integer scalar arrays can be converted to a scalar index</code></p>
  
  <p>My best guess is that this is based on the fact that <code>groupby</code> returns a <code>groupby object</code>? Or should this work with a <code>groupby</code> object as well?</p>
  
  <p>What are my options here? Maybe my <code>groupby</code> is wrong? Maybe I don't need a <code>groupby</code>? Maybe I can convert my <code>groupby</code> object to a <code>dataframe</code> and then run the <code>df.at</code>? Any help is appreciated.</p>
  
  <p>Also - if I've done something wrong, please help me understand the 'why?' along with the fixed scripting. I am very interested in learning as much as I can vs. having everyone do my work for me. I love python and the capabilities, but am very much a novice at this point.</p>
  
  <p>Cheers</p>