title: Data Frame from an existing RDD - Python Spark
body: <p>I am trying to create a Data Frame from an existing RDD by specifying the column label and data type, but I get this Typeerror:</p>
  
  <pre class="lang-py prettyprint-override"><code>from pyspark.sql import SQLContext
  from pyspark.sql.types import *
  
  sqlContext = SQLContext(sc)
  yFieldTypes = [FloatType()]
  ySchemaString = "Predictor"
  fy_data = [StructField(field_name, field_type, True) \
            for field_name, field_type in zip(ySchemaString.split(), yFieldTypes)]
  schema_y = StructType(fy_data)
  </code></pre>
  
  <p>So the schema is as follows: </p>
  
  <pre><code>StructType(List(StructField(Predictor,FloatType,true)))
  </code></pre>
  
  <p>And my RDD datay.take(10) output is as follows:</p>
  
  <pre><code> [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  </code></pre>
  
  <p>When I want to create my data frame:</p>
  
  <pre class="lang-py prettyprint-override"><code>dfy = sqlContext.createDataFrame(datay, schema_y)
  </code></pre>
  
  <p>I get this Typeerror:</p>
  
  <pre><code>TypeError: StructType(List(StructField(Predictor,FloatType,true))) can not accept object in type &lt;type 'float'&gt;   
  </code></pre>