pyspark.sql.DataFrame.printSchema

DataFrame.printSchema() → None[source]

Prints out the schema in the tree format.

New in version 1.3.0.

Changed in version 3.4.0: Supports Spark Connect.

Examples

>>> df = spark.createDataFrame(
...     [(14, "Tom"), (23, "Alice"), (16, "Bob")], ["age", "name"])
>>> df.printSchema()
root
 |-- age: long (nullable = true)
 |-- name: string (nullable = true)