title: Error: TimestampType can not accept object while creating a Spark dataframe from a list
body: <p>I am trying to create a dataframe from the following list:</p>
  <pre><code>data = [(1,'abc','2020-08-20 10:00:00', 'I'),
  (1,'abc','2020-08-20 10:01:00', 'U'),
  (1,'abc','2020-08-21 10:02:00', 'U'),
  (2,'pqr','2020-08-20 10:00:00', 'I'),
  (2,'pqr','2020-08-20 10:01:00', 'U'),
  (2,'pqr','2020-08-21 10:02:00', 'D'),
  (3,'rst','2020-08-20 10:00:00', 'I'),
  (3,'rst','2020-08-20 10:01:00', 'U'),
  (3,'rst','2020-08-21 10:02:00', 'U')]
  </code></pre>
  <p>I am running the following code to create a dataframe from this:</p>
  <pre><code>from pyspark.sql.types import *
  mySchema = StructType([StructField(&quot;key&quot;, IntegerType()),
                        StructField(&quot;name&quot;, StringType()),
                        StructField(&quot;ts&quot;, TimestampType()),
                        StructField(&quot;cdc_flag&quot;, StringType())])
  
  df_raw = spark.createDataFrame(data, mySchema)
  </code></pre>
  <p>And I am getting the following error:</p>
  <pre><code>TypeError: field ts: TimestampType can not accept object '2020-08-20 10:00:00' in type &lt;class 'str'&gt;
  </code></pre>
  <p>I tried changing the data type to DateType also. But getting the same error.</p>
  <p>Please note that, I am trying to understand if this way of implementing the schema is possible or not.
  I think I can use withColumn and cast this ts column and drop the original column to handle this.</p>