---
title: schema (DataFrame)
description: "DataFrame.schema property in PySpark: Returns the schema of this DataFrame as a StructType."
canonical_url: https://docs.databricks.com/gcp/en/pyspark/reference/classes/dataframe/schema
---

# schema (DataFrame)

Returns the schema of this `DataFrame` as a `StructType`.

## Returns

`StructType`

## Examples

Retrieve the inferred schema of the current DataFrame.

```python
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.

```python
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.

```python
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)])
```
