# If Then

This function creates a new column based on the conditions provided in the `conditions` argument.

Output values should be of the same type, since they are constructing one new column.

A default value for the new column should be set, as should the output column name.

## Parameters

| Name       | Type              | Description                                                                                                                       | Is Optional |
| ---------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| conditions | conditional\_list | A nested list. In each inner list the first element would be the condition to check, and the second the value with which to fill. |             |
| default    | mixed\_value      | The default value with which to fill the new column. Please enclose fixed strings in quotes inside of the argument (e.g., below)  |             |
| alias      | string            | The name of the output column in the new dataset.                                                                                 |             |

## Example

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

ds2 = ds.if_then(conditions=[["DS_WEATHER_ICON like '%cloudy%'", 1]],
      default=2,
      alias="CLOUDY_WEATHER_FLAG")
ds2.preview()
```

## Source Code

{% embed url="<https://github.com/rasgointelligence/RasgoTransforms/blob/main/rasgotransforms/rasgotransforms/transforms/if_then/if_then.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/if_then.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.
