---
title: isin
description: "Column.isin method in PySpark: Check if the column value is in a list of values."
canonical_url: https://docs.databricks.com/gcp/en/pyspark/reference/classes/column/isin
---

# isin

Check if the column value is in a list of values.

## Syntax

```python
isin(*cols)
```

## Parameters

| Parameter | Type   | Description                     |
| --------- | ------ | ------------------------------- |
| `cols`    | values | List of values to check against |

## Returns

Column (boolean)

## Examples

Example 1: Filter rows with names in the specified values.

```python
df = spark.createDataFrame([(2, "Alice"), (5, "Bob"), (8, "Mike")], ["age", "name"])
df[df.name.isin("Bob", "Mike")].orderBy("age").show()
```

```Output
# +---+----+
# |age|name|
# +---+----+
# |  5| Bob|
# |  8|Mike|
# +---+----+
```

Example 2: Filter rows with ages in the specified list.

```python
df[df.age.isin([1, 2, 3])].show()
```

```Output
# +---+-----+
# |age| name|
# +---+-----+
# |  2|Alice|
# +---+-----+
```

Example 3: Filter rows with names not in the specified values.

```python
df[~df.name.isin("Alice", "Bob")].show()
```

```Output
# +---+----+
# |age|name|
# +---+----+
# |  8|Mike|
# +---+----+
```

Example 4: Use a DataFrame as an IN subquery.

```python
df.where(df.age.isin(spark.range(6))).orderBy("age").show()
```

```Output
# +---+-----+
# |age| name|
# +---+-----+
# |  2|Alice|
# |  5|  Bob|
# +---+-----+
```
