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.
Returns the schema of this DataFrame as a StructType.
Returns
StructType
Examples
Retrieve the inferred schema of the current DataFrame.
df = spark.createDataFrame(
[(14, "Tom"), (23, "Alice"), (16, "Bob")], ["age", "name"])
df.schema
# StructType([StructField('age', LongType(), True),
# StructField('name', StringType(), True)])
Retrieve the schema of the current DataFrame from a DDL-formatted schema string.
df = spark.createDataFrame(
[(14, "Tom"), (23, "Alice"), (16, "Bob")],
"age INT, name STRING")
df.schema
# StructType([StructField('age', IntegerType(), True),
# StructField('name', StringType(), True)])
Retrieve the specified schema of the current DataFrame.
from pyspark.sql.types import StructType, StructField, StringType
df = spark.createDataFrame(
[("a",), ("b",), ("c",)],
StructType([StructField("value", StringType(), False)]))
df.schema
# StructType([StructField('value', StringType(), False)])