How to get a value from the Row object in Spark Dataframe? : <p>for </p>

<pre><code>averageCount = (wordCountsDF
                .groupBy().mean()).head()
</code></pre>

<p>I get</p>

<blockquote>
  <p>Row(avg(count)=1.6666666666666667)</p>
</blockquote>

<p>but when I try:</p>

<pre><code>averageCount = (wordCountsDF
                .groupBy().mean()).head().getFloat(0)
</code></pre>

<p>I get the following error:</p>

<blockquote>
  <p>AttributeError: getFloat
  --------------------------------------------------------------------------- AttributeError                            Traceback (most recent call
  last)  in ()
        1 # TODO: Replace  with appropriate code
  ----> 2 averageCount = (wordCountsDF
        3                 .groupBy().mean()).head().getFloat(0)
        4 
        5 print averageCount</p>
  
  <p>/databricks/spark/python/pyspark/sql/types.py in <strong>getattr</strong>(self,
  item)    1270             raise AttributeError(item)    1271<br>
  except ValueError:
  -> 1272             raise AttributeError(item)    1273     1274     def <strong>setattr</strong>(self, key, value):</p>
  
  <p>AttributeError: getFloat</p>
</blockquote>

<p>What am I doing wrong?</p>
