Бележка
Достъпът до тази страница изисква удостоверяване. Можете да опитате да влезете или да промените директориите.
Достъпът до тази страница изисква удостоверяване. Можете да опитате да промените директориите.
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)])