---
title: conv
description: "conv function in PySpark: Convert a number in a string column from one base to another."
canonical_url: https://docs.databricks.com/aws/en/pyspark/reference/functions/conv
---

# conv

Convert a number in a string column from one base to another. Supports Spark Connect.

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

## Syntax

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

dbf.conv(col=<col>, fromBase=<fromBase>, toBase=<toBase>)
```

## Parameters

| Parameter  | Type                        | Description                   |
| ---------- | --------------------------- | ----------------------------- |
| `col`      | `pyspark.sql.Column or str` | a column to convert base for. |
| `fromBase` | `int`                       | from base number.             |
| `toBase`   | `int`                       | to base number.               |

## Returns

`pyspark.sql.Column`: logariphm of given value.

## Examples

```python
from pyspark.sql import functions as dbf
df = spark.createDataFrame([("010101",), ( "101",), ("001",)], ['n'])
df.select("*", dbf.conv(df.n, 2, 16)).show()
```

```Output
+------+--------------+
|     n|conv(n, 2, 16)|
+------+--------------+
|010101|            15|
|   101|             5|
|   001|             1|
+------+--------------+
```
