I need to define the types of columns within the spark.createDataFrame()
. For example, I need to define the format of columns Age and Weight, and I'm using the following code:
from pyspark.sql.types import IntegerType, FloaType
Age1 = Spark.createDataFrame(df['Age'], IntegerType ())
Weight1 = Spark.createDataFrame(df['Weight'], FloatType ())
How can I do it inside a single spark.createDataFrame
instead of creating two?