---
title: sign
description: "sign function in PySpark: Computes the signum of the given value."
canonical_url: https://docs.databricks.com/aws/en/pyspark/reference/functions/sign
---

# sign

Computes the signum of the given value. Supports Spark Connect.

For the corresponding Databricks SQL function, see [`sign` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/sign.md).

## Syntax

```python
from pyspark.sql import functions as dbf

dbf.sign(col=<col>)
```

## Parameters

| Parameter | Type                                | Description                  |
| --------- | ----------------------------------- | ---------------------------- |
| `col`     | `pyspark.sql.Column or column name` | target column to compute on. |

## Returns

`pyspark.sql.Column`: the column for computed results.

## Examples

```python
from pyspark.sql import functions as dbf
spark.range(1).select(
    dbf.sign(dbf.lit(-5)),
    dbf.sign(dbf.lit(6)),
    dbf.sign(dbf.lit(float('nan'))),
    dbf.sign(dbf.lit(None))
).show()
```

```Output
+--------+-------+---------+----------+
|sign(-5)|sign(6)|sign(NaN)|sign(NULL)|
+--------+-------+---------+----------+
|    -1.0|    1.0|      NaN|      NULL|
+--------+-------+---------+----------+
```
