# Replace Missing

Replace missing values in column/columns with the mean, median, mode, or a value

## Parameters

| Name                | Type             | Description                                                                                                                                             | Is Optional |
| ------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| replacements        | imputation\_dict | Dictionary with keys as column names to replace missing values for, and dictionary values the type of replacement strategy ('mean', 'median', 'mode', ) |             |
| flag\_missing\_vals | boolean          | Use True to create an indicator column for when a value was replaced. This column will be named like '\<col\_name>\_missing\_flag'.                     | True        |

## Example

```python
ds = rasgo.get.dataset(id)

ds2 = ds.replace_missing(
  replacements={
      'MONTH': 'mean',            # Replace with mean 
      'FIPS': 'median',           # Replace with median
      'COVID_NEW_CASES': 'mode',  # Replace with mode
      'YEAR': '2021',             # Replace with the string '2021'
      'COVID_DEATHS': 2.45       # Replace with the number 2.45
  },
  flag_missing_vals=True)

ds2.preview()
```

## Source Code

{% embed url="<https://github.com/rasgointelligence/RasgoTransforms/blob/main/rasgotransforms/rasgotransforms/transforms/replace_missing/replace_missing.sql>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rasgoml.com/rasgo-docs/rasgo-0.1/all-transforms/replace_missing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
