title: How to convert DataFrame columns from string to float/double in PySpark 1.6?
body: <p>In PySpark 1.6 DataFrame currently there is no Spark builtin function to convert from string to float/double.</p>
  <p>Assume, we have a RDD with ('house_name', 'price') with both values as string. You would like to convert, price from string to float.
  In PySpark, we can apply map and python float function to achieve this.</p>
  <pre><code>New_RDD = RawDataRDD.map(lambda (house_name, price): (house_name, float(x.price))    # this works
  </code></pre>
  <p>In PySpark 1.6 Dataframe, it does not work:</p>
  <pre><code>New_DF = rawdataDF.select('house name', float('price')) # did not work
  </code></pre>
  <p>Until a built in Pyspark function available, how to do achieve this conversion with a UDF?
  I developed this conversion UDF as follows:</p>
  <pre><code>from pyspark.sql.functions import udf
  from pyspark.sql.types import StringType
  
  def string_to_float(x):
      return float(x)
  
  udfstring_to_float = udf(string_to_float, StringType())
  rawdata.withColumn(&quot;house name&quot;, udfstring_to_float(&quot;price&quot;))
  </code></pre>
  <p>Is there a better and much simpler way to achieve the same?</p>