Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2016 10:03 AM
The
castfunction can convert the specified columns into different dataTypes. You shouldn't need a UDF to do this. If rawdata is a DataFrame, this should work:
https://spark.apache.org/docs/latest/api/python/pyspark.sql.html#pyspark.sql.Column.cast
df = rawdata.select(col('house name'), rawdata.price.cast('float').alias('price'))