---
title: fill (DataFrameNaFunctions) s
description: "DataFrameNaFunctions.fill method in PySpark: Returns a new DataFrame in which null values are filled with a new value."
canonical_url: https://docs.databricks.com/aws/en/pyspark/reference/classes/dataframenafunctions/fill
---

# fill (DataFrameNaFunctions) s

Returns a new `DataFrame` in which null values are filled with a new value. `DataFrame.fillna` and `DataFrameNaFunctions.fill` are aliases of each other.

## Syntax

```
fill(value, subset=None)
```

## Parameters

| Parameter | Type                           | Description                                                                                                                                                                                                 |
| --------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `value`   | int, float, str, bool, or dict | The value to replace null values with. If a dict is provided, `subset` is ignored and `value` must be a mapping from column name to replacement value. Replacement values must be int, float, bool, or str. |
| `subset`  | str, tuple, or list, optional  | Column names to consider. Columns in `subset` that do not have a matching data type for `value` are ignored.                                                                                                |

## Returns

`DataFrame`

## Examples

```python
df = spark.createDataFrame([
    (10, 80.5, "Alice", None),
    (5, None, "Bob", None),
    (None, None, "Tom", None),
    (None, None, None, True)],
    schema=["age", "height", "name", "bool"])
```

Fill all null values with 50 for numeric columns.

```python
df.na.fill(50).show()
# +---+------+-----+----+
# |age|height| name|bool|
# +---+------+-----+----+
# | 10|  80.5|Alice|NULL|
# |  5|  50.0|  Bob|NULL|
# | 50|  50.0|  Tom|NULL|
# | 50|  50.0| NULL|true|
# +---+------+-----+----+
```

Fill all null values with `False` for boolean columns.

```python
df.na.fill(False).show()
# +----+------+-----+-----+
# | age|height| name| bool|
# +----+------+-----+-----+
# |  10|  80.5|Alice|false|
# |   5|  NULL|  Bob|false|
# |NULL|  NULL|  Tom|false|
# |NULL|  NULL| NULL| true|
# +----+------+-----+-----+
```

Fill null values with 50 for `age` and `"unknown"` for `name`.

```python
df.na.fill({'age': 50, 'name': 'unknown'}).show()
# +---+------+-------+----+
# |age|height|   name|bool|
# +---+------+-------+----+
# | 10|  80.5|  Alice|NULL|
# |  5|  NULL|    Bob|NULL|
# | 50|  NULL|    Tom|NULL|
# | 50|  NULL|unknown|true|
# +---+------+-------+----+
```

Fill all null values with `"Spark"` for the `name` column.

```python
df.na.fill(value='Spark', subset='name').show()
# +----+------+-----+----+
# | age|height| name|bool|
# +----+------+-----+----+
# |  10|  80.5|Alice|NULL|
# |   5|  NULL|  Bob|NULL|
# |NULL|  NULL|  Tom|NULL|
# |NULL|  NULL|Spark|true|
# +----+------+-----+----+
```
