PythonCode
Allows for custom Python code to be executed against tables and objects inside an AuditBoard Analytics Workflow. One can ingest any number of sources and output any number of objects.

Input, Output
No requirements, any number of tables or inputs is allowed
Any python altered data frames or charts dictated by return
Accessing Objects & Parameters
Any source linked to the Python 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 parameters are available using the variables
dictionary. It's recommended to access parameter by their name:
foo = variables["foo"]
Returning Objects
AuditBoard Analytics allows the return of Table
or Chart
objects for use in downstream tools. Objects can be returned as a single object or an array of objects.
Table
To create and return a table, provide a name
and pandas df
attribute to the Table
object.
import pandas as pd
tbl = sources[0]
df = tbl.df
return [Table(df=df, name="DataFrame")]
Chart
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])],
layout=go.Layout(
title=go.layout.Title(text="A Figure Specified By A Graph Object")
)
)
return Chart(name="foo", figure=fig)
Within the Code tool, the following libraries are accessible by default. Import libraries using import
:
Last updated
Was this helpful?