title: How to typecast Spark DataFrame columns? Using pyspark
body: <p>I have created a DataFrame in the following way:</p>
  
  <pre><code>from pyspark.sql import SparkSession
  spark = SparkSession \
      .builder \
      .appName("Python Spark SQL basic example") \
      .getOrCreate()
  
  df = spark.read.csv("train.csv", header=True)
  </code></pre>
  
  <p>The schema for my DataFrame is as follows:</p>
  
  <pre><code>root
   |-- PassengerId: string (nullable = true)
   |-- Survived: string (nullable = true)
   |-- Pclass: string (nullable = true)
   |-- Name: string (nullable = true)
   |-- Sex: string (nullable = true)
   |-- Age: string (nullable = true)
   |-- SibSp: string (nullable = true)
   |-- Parch: string (nullable = true)
   |-- Ticket: string (nullable = true)
   |-- Fare: string (nullable = true)
   |-- Cabin: string (nullable = true)
   |-- Embarked: string (nullable = true)
  </code></pre>
  
  <p>How do I change the data types of each column of my DataFrame?</p>
  
  <p>I know that I can specify the schema option in the call to csv(), but I want to change the data types after at a later stage.</p>
  
  <p>Some of the columns have missing values. How do Spark DataFrames deal with missing values?</p>