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:

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.

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

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.

Kindly click the "Preview" button for this purpose.

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.

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

In case of failed running

Note: After the Script node cannot add another node.

Last updated