title: How to get the schema definition from a dataframe in PySpark?
body: <p>In PySpark it you can define a schema and read data sources with this pre-defined schema, e. g.:</p>
  
  <pre class="lang-py prettyprint-override"><code>Schema = StructType([ StructField("temperature", DoubleType(), True),
                        StructField("temperature_unit", StringType(), True),
                        StructField("humidity", DoubleType(), True),
                        StructField("humidity_unit", StringType(), True),
                        StructField("pressure", DoubleType(), True),
                        StructField("pressure_unit", StringType(), True)
                      ])
  </code></pre>
  
  <p>For some datasources it is possible to infer the schema from the data-source and get a dataframe with this schema definition.</p>
  
  <p>Is it possible to get the schema definition (in the form described above) from a dataframe, where the data has been inferred before?</p>
  
  <p><code>df.printSchema()</code> prints the schema as a tree, but I need to reuse the schema, having it defined as above,so I can read a data-source with this schema that has been inferred before from another data-source.</p>