---
title: otherwise
description: "Column.otherwise method in PySpark: Specify a default value for when conditions in when() are not met."
canonical_url: https://docs.databricks.com/gcp/en/pyspark/reference/classes/column/otherwise
---

# otherwise

Specify a default value for when conditions in `when()` are not met.

## Syntax

```python
otherwise(value)
```

## Parameters

| Parameter | Type  | Description             |
| --------- | ----- | ----------------------- |
| `value`   | value | Default value to return |

## Returns

Column

## Examples

```python
from pyspark.sql import functions as sf
df = spark.createDataFrame(
     [(2, "Alice"), (5, "Bob")], ["age", "name"])
df.select(df.name, sf.when(df.age > 3, 1).otherwise(0)).show()
```

```Output
# +-----+-------------------------------------+
# | name|CASE WHEN (age > 3) THEN 1 ELSE 0 END|
# +-----+-------------------------------------+
# |Alice|                                    0|
# |  Bob|                                    1|
# +-----+-------------------------------------+
```
