title: How to create dataframe with struct column in PySpark without specifying a schema?
body: <p>I am learning PySpark and it is convenient to be able to quickly create example dataframes to try the functionality of the PySpark API.</p>
  <p>The following code (where <code>spark</code> is a spark session):</p>
  <pre class="lang-py prettyprint-override"><code>import pyspark.sql.types as T
  df = [{'id': 1, 'data': {'x': 'mplah', 'y': [10,20,30]}},
        {'id': 2, 'data': {'x': 'mplah2', 'y': [100,200,300]}},
  ]
  df = spark.createDataFrame(df)
  df.printSchema()
  </code></pre>
  <p>gives a map (and does not interpret the array correctly):</p>
  <pre class="lang-none prettyprint-override"><code>root
   |-- data: map (nullable = true)
   |    |-- key: string
   |    |-- value: string (valueContainsNull = true)
   |-- id: long (nullable = true)
  </code></pre>
  <p>I needed a struct. I can force a struct if I give a schema:</p>
  <pre class="lang-py prettyprint-override"><code>import pyspark.sql.types as T
  df = [{'id': 1, 'data': {'x': 'mplah', 'y': [10,20,30]}},
        {'id': 2, 'data': {'x': 'mplah2', 'y': [100,200,300]}},
  ]
  schema = T.StructType([
      T.StructField('id', LongType()),
      T.StructField('data', StructType([
          StructField('x', T.StringType()),
          StructField('y', T.ArrayType(T.LongType())),
      ]) )
  ])
  df = spark.createDataFrame(df, schema=schema)
  df.printSchema()
  </code></pre>
  <p>That indeed gives:</p>
  <pre class="lang-none prettyprint-override"><code>root
   |-- id: long (nullable = true)
   |-- data: struct (nullable = true)
   |    |-- x: string (nullable = true)
   |    |-- y: array (nullable = true)
   |    |    |-- element: long (containsNull = true)
  </code></pre>
  <p>But this is too much typing.</p>
  <p>Is there any other quick way to create the dataframe so that the data column is a struct without specifying the schema?</p>