# Evaluate

**Evaluate** &#x20;

Given an expression evaluates the expression string. If performed on the data frame row, it evaluates via passing the row as a dictionary. If performed on a single value, it expects an additional argument 'key' to be used in the expression. \
@param expr: The expression to evaluate. \
@param key: An optional 'key' if evaluated on a single value instead of a dictionary.

To perform arithmetic operations on columns, evaluate function is used. This function works on data type with 'Numeric' columns (Float or Integer).&#x20;

{% hint style="info" %}
To perform arithmetic operations on columns, make sure the column's data type is set to '**Integer**' (Numeric) or '**Float**'. Additionally, column values should not contain **NULL** or **Empty** values.
{% endhint %}

### Example 1:&#x20;

Note - This example demos the use of the 'dm: map evaluate' function using expression to calculate total VM CPU count.

Step 1: Create an empty **evaluate\_example\_1** using AIOps studio as shown in the below screenshot.

![](/files/-McuVYIQIUTR-8USQ_RX)

Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:

You can copy the below code into your pipeline and execute that in your environment.\
\
\&#xNAN;*`##### This pipeline creates a list of rows with vm_cpu_sockets along with vm_cpu_cores`* \
*`##### for virtual machines using AIOps studio.`*\
\
*`##### RDA function 'Evaluate' is used to demo this example that uses expression`*\
*`##### to calculate total CPU allocated to each virtual machine.`*\
\
*`@dm:empty`* \
&#x20;   *`--> @dm:addrow vm_cpu_sockets = 1 & vm_cpu_cores = 3 & vm_id = 'vm1'`*\
&#x20;   *`--> @dm:addrow vm_cpu_sockets = 2 & vm_cpu_cores = 8 & vm_id = 'vm1'`*\
&#x20;   *`--> @dm:addrow vm_cpu_sockets = 1 & vm_cpu_cores = 2 & vm_id = 'vm1'`*\
&#x20;   *`--> @dm:addrow vm_cpu_sockets = 2 & vm_cpu_cores = 4 & vm_id = 'vm1'`*\
&#x20;   *`--> @dm:addrow vm_cpu_sockets = 2 & vm_cpu_cores = 8 & vm_id = 'vm1'`*\
&#x20;   *`--> @dm:addrow vm_cpu_sockets = 1 & vm_cpu_cores = 2 & vm_id = 'vm1'`*\
&#x20;   *`--> @dm:map to = 'vm_cpu_total' & func = 'evaluate' & expr = 'vm_cpu_sockets * vm_cpu_cores'`*<br>

![Pipeline code added to example pipeline via AIOps Studio](/files/-McufUWN3vh8I0KkU1N4)

Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)

![Click 'Verify' will validate the pipeline syntax and prints as shown above.](/files/-Mcufs-Bg-3gVohm_yrx)

Step 4:  Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)

![Sucessful execution of pipeline](/files/-McugFc67_TowBR1kaqb)

Step 5: RDA uses the evaluate function to calculate 'vm\_cpu\_total' (using expression as shown in the pipeline code snippet) as shown in the below screenshot.

![After successful execution of pipeline, inspect provides the output from evaluate function execution](/files/-McuhCk0vL8SxwJ1IhOM)

### Example 2:

&#x20;Step 1: Create an empty **evaluate\_example\_2** using AIOps studio as shown in the below screenshot.

Note -  In the below example, **vm\_disk\_size\_bytes** is a column that has disk capacity in bytes, using the  '**evaluate**' function, create a new column '**vm\_disk\_size\_gb'** and convert the bytes into GB.

![](/files/-McujT018SI7-J4_0EPX)

Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:

You can copy the below code into your pipeline and execute that in your environment.&#x20;

using the  '**evaluate**' function, create a new column '**vm\_disk\_size\_gb'** and convert the bytes into GB.\
\
\&#xNAN;*`##### This pipeline creates a list of rows with vm_disk_size_bytes column that has`*\
*`##### disk capacity in bytes. Pipeline uses 'evaluate' function and maps to new column`*\
*`##### and convert the data into 'vm_disk_size_gb'`*\
\
*`##### RDA function 'Evaluate' is used to demo this example that uses expression`*\
*`##### to calculate 'vm_disk_size_gb'`*\
\
*`@dm:empty`* \
&#x20;   *`--> @dm:addrow vm_disk_size_bytes = 10737418240  & vm_id = 'vm1'`*\
&#x20;   *`--> @dm:addrow vm_disk_size_bytes = 322122542    & vm_id = 'vm2'`*\
&#x20;   *`--> @dm:addrow vm_disk_size_bytes = 21474836480  & vm_id = 'vm3'`*\
&#x20;   *`--> @dm:addrow vm_disk_size_bytes = 322122542    & vm_id = 'vm4'`*\
&#x20;   *`--> @dm:addrow vm_disk_size_bytes = 53687091200  & vm_id = 'vm5'`*\
&#x20;   *`--> @dm:map from = 'vm_disk_size_bytes' & to = 'vm_disk_size_in_gb'`*\
&#x20;   *`--> @dm:map attr = 'vm_disk_size_gb' & func = 'evaluate' & expr = 'vm_disk_size_gb/1024 /1024 /1024 '`* \
&#x20;  &#x20;

![](/files/-McuoQVLaNTBxkDYKXg7)

Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)

![PIpeline verification with out any errors.](/files/-McuoqWdxz8Boo5CmGJ3)

Step 4:  Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)

![Pipeline execution without any errors](/files/-McupHeVG5WfGWdU1RyD)

Step 5: RDA uses the evaluate function to calculate '**vm\_disk\_size\_gb**' (using expression as shown in the pipeline code snippet) as shown in the below screenshot.&#x20;

![After successful execution of pipeline, inspect provides the output from evaluate function execution](/files/-Mcuq71UnXYBtzfzZzMF)

Similar to the above-provided examples, users can upload any files that require any mathematical calculation and use the 'evaluate' function/expression to print or store the data.


---

# 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.cloudfabrix.io/rda/rda-userguide/rda-aiops-studio/examples-jupyter/data-mapping-cfxdm-dm-functions/evaluate.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.
