Insert custom Python code

This tool is currently in Beta and is still being tested. Want to learn more? Like to provide feedback? Please reach out to

Code allows for custom Python to be executed against tables and objects inside a Cascade Workflow. One can ingest any number of sources and output any number of objects.

Accessing Objects & Variables

Any source linked to the Code tool is accessible using the sources dictionary, and objects can be accessed by their index or by their name. For example:

df1 = sources[0].df        # access table by index
df1 = sources["foo"].df    # access table by name

Similarly, workflow variables are available using the variables dictionary. It's recommended to access variables by their name:

foo = variables["foo"]

Returning Objects

Cascade allows the return of Table, Chart , Json, or Markdown objects for use in downstream tools. Objects can be returned as a single object or an array of objects.


To create and return a table, provide a name and pandas df attribute to the Table object.

return Table (
     name = "foo"
     df = df1


To create and return a chart, provide a name and plotly figure attribute to the Chart object.

import plotly.graph_objects as go

fig = go.Figure(
    data=[go.Bar(x=[1, 2, 3], y=[1, 3, 2])],
        title=go.layout.Title(text="A Figure Specified By A Graph Object")

return Chart(name="foo", figure=fig)


To create and return a json, provide a name and python dict attribute to the JSON object.

return Json(name="foo", json={"counter": 1})


To create and return a json, provide a name and python dict attribute to the JSON object.

return Markdown(name="foo", markdown="# Hello")

Available Libraries

Within the Code tool, the following libraries are accessible by default. Import libraries using import:




Data manipulation

import pandas

API requests

import requests

JSON handling

import json

Numerical and statistical operations

import numpy

Regressions and machine learning

import sklearn

Time-series forecasting

from fbprophet import Prophet

Feature engineering

import featuretools

Machine learning

import evalml

Time series forecasting and classification

import sktime

Fuzzy matching for data cleaning

import fuzzymatcher

Fuzzy matching for data cleaning

import recordlinkage

API requests

import requests

Math and engineering

import scipy

Web scraping

import scrapy

Web scraping

from bs4 import BeautifulSoup


URL Encoding/decoding

import urllib

Last updated