Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
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)