Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Prints out the schema in the tree format. Optionally allows to specify how many levels to print if schema is nested.
Syntax
printSchema(level: Optional[int] = None)
Parameters
| Parameter | Type | Description |
|---|---|---|
level |
int, optional | How many levels to print for nested schemas. |
Examples
df = spark.createDataFrame(
[(14, "Tom"), (23, "Alice"), (16, "Bob")], ["age", "name"])
df.printSchema()
# root
# |-- age: long (nullable = true)
# |-- name: string (nullable = true)
df = spark.createDataFrame([(1, (2, 2))], ["a", "b"])
df.printSchema(1)
# root
# |-- a: long (nullable = true)
# |-- b: struct (nullable = true)
df.printSchema(2)
# root
# |-- a: long (nullable = true)
# |-- b: struct (nullable = true)
# | |-- _1: long (nullable = true)
# | |-- _2: long (nullable = true)