---
title: chr
description: "chr function in PySpark: Returns the ASCII character having the binary equivalent to n. If n is larger than 256 the result is equivalent to chr(n % 256)."
canonical_url: https://docs.databricks.com/aws/en/pyspark/reference/functions/chr
---

# chr

Returns the ASCII character having the binary equivalent to `n`. If `n` is larger than 256 the result is equivalent to `chr(n % 256)`.

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

## Syntax

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

dbf.chr(n=<n>)
```

## Parameters

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

## Examples

```python
from pyspark.sql import functions as dbf
spark.range(60, 70).select("*", dbf.chr("id")).show()
```

```Output
 +---+-------+
 | id|chr(id)|
 +---+-------+
 | 60|      <|
 | 61|      =|
 | 62|      >|
 | 63|      ?|
 | 64|      @|
 | 65|      A|
 | 66|      B|
 | 67|      C|
 | 68|      D|
 | 69|      E|
 +---+-------+
```
