---
title: format (DataFrameWriter)
description: "DataFrameWriter.format method in PySpark: Specifies the underlying output data source."
canonical_url: https://docs.databricks.com/gcp/en/pyspark/reference/classes/dataframewriter/format
---

# format (DataFrameWriter)

Specifies the underlying output data source.

## Syntax

```
format(source)
```

## Parameters

| Parameter | Type | Description                                                       |
| --------- | ---- | ----------------------------------------------------------------- |
| `source`  | str  | The name of the data source, for example `'json'` or `'parquet'`. |

## Returns

`DataFrameWriter`

## Examples

Write a DataFrame into a Parquet file and read it back.

```python
import tempfile
with tempfile.TemporaryDirectory(prefix="format") as d:
    spark.createDataFrame(
        [{"age": 100, "name": "Alice"}]
    ).write.mode("overwrite").format("parquet").save(d)

    spark.read.format('parquet').load(d).show()
    # +---+------------+
    # |age|        name|
    # +---+------------+
    # |100|Alice|
    # +---+------------+
```
