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

# option (DataFrameWriter)

Adds an output option for the underlying data source.

For available options, see [DataFrameWriter options](https://docs.databricks.com/gcp/en/spark/api-options.md#batch-write-options).

## Syntax

```
option(key, value)
```

## Parameters

| Parameter | Type                     | Description       |
| --------- | ------------------------ | ----------------- |
| `key`     | str                      | The option key.   |
| `value`   | str, int, float, or bool | The option value. |

## Returns

`DataFrameWriter`

## Examples

Write a DataFrame into a CSV file with the `nullValue` option set.

```python
import tempfile
with tempfile.TemporaryDirectory(prefix="option") as d:
    df = spark.createDataFrame([(100, None)], "age INT, name STRING")
    df.write.option("nullValue", "Alice").mode("overwrite").format("csv").save(d)

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