> For the complete documentation index, see [llms.txt](https://docs.antsomi.com/cdp-365-user-guide-en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.antsomi.com/cdp-365-user-guide-en/dataflows/dataflows/creating-a-dataflows/action-node/script.md).

# Script

If you intend to employ Python code within the dataflow for data transformation before exporting it from CDP 365, this document will be beneficial to you.

## Step 1: Add the Script node to your dataflow

For reference to the node, please consult the image provided below:

<figure><img src="https://826840553-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbtU4vFUxT5JkWYHePuoX%2Fuploads%2FVvtzsYDCNwUOAG0RIiQx%2Fimage.png?alt=media&amp;token=f3324b17-a635-43d2-8513-e8b96531bf25" alt=""><figcaption><p>Add the Script node</p></figcaption></figure>

***Note:** After the Script node cannot add another node.*

## Step 2: Write your Python code

It has 3 zones:

* Zone **1** outlines the attributes prepared for transformation
* Zone **2** places your Python code within it
* Zone **3** involves modifying the coding theme and default fields of CDP 365.

<figure><img src="https://826840553-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbtU4vFUxT5JkWYHePuoX%2Fuploads%2FC2tTt4S04CLuQLRUq8mx%2Fimage.png?alt=media&amp;token=a31b14bb-a962-4a13-aa81-9b8d7874e6f8" alt=""><figcaption><p>Write Python code</p></figcaption></figure>

For reference to the transforming result, please consult the code below:

```python
import pandas
import sys

# Load data from system
df = pandas.read_csv(sys.argv[1])

# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script: 
dataset = pandas.DataFrame(df)
dataset = dataset.drop_duplicates()

# Paste or type your script code here:

print(dataset)
```

## Step 3: Preview the transformed data

Before executing the code, it's essential to preview it beforehand to **ensure that the data is prepared for transformation within the Script node**.&#x20;

Kindly click the "**Preview**" button for this purpose.

<figure><img src="https://826840553-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbtU4vFUxT5JkWYHePuoX%2Fuploads%2FmR23H4WVDiLLyZjkK5iL%2Fimage.png?alt=media&amp;token=a178df65-0364-4bcb-af06-18ecd73063ca" alt=""><figcaption><p>Preview the data</p></figcaption></figure>

## Step 4: Test the Script node

Once you've successfully previewed the data and confirmed its accuracy, you can proceed to run the code. Kindly click the "**Test**" button to do so.

<figure><img src="https://826840553-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbtU4vFUxT5JkWYHePuoX%2Fuploads%2FfCLc2GOYD8Zwy5m6UOPR%2Fimage.png?alt=media&amp;token=4e748784-8c89-43ed-b5b9-ba22af3e0a27" alt=""><figcaption><p>Run the code</p></figcaption></figure>

## Step 5: Check the running status

Upon executing the code, a banner will appear from the **lower-left corner** of your screen. Kindly inspect this banner to monitor the **status** of the execution.

### In case of successful running

<figure><img src="https://826840553-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbtU4vFUxT5JkWYHePuoX%2Fuploads%2Ft9zAfe0CTqcgQ4OblFBN%2Fimage.png?alt=media&amp;token=73e2f172-757f-4b7a-a8c0-2008de8de000" alt=""><figcaption><p>Success test</p></figcaption></figure>

### In case of failed running

<figure><img src="https://826840553-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbtU4vFUxT5JkWYHePuoX%2Fuploads%2Fnu5D45VraMHC0KJCt1rd%2Fimage.png?alt=media&amp;token=af8727b5-cc18-4c5f-800e-cd180ad48c58" alt=""><figcaption><p>Failed test</p></figcaption></figure>

***Note:** After the Script node cannot add another node.*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.antsomi.com/cdp-365-user-guide-en/dataflows/dataflows/creating-a-dataflows/action-node/script.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
