Analytics
  • Introductions
    • 👋Hello Analytics!
    • 👩‍🎓Workflow Philosophy
    • 📹Build a Workflow
    • 🖨️Start from a Template
      • 3 Way Match
      • Accounts Payable - Analytical Review
      • Accounts Payable - Debt Aging and Approval
      • Accounts Receivable - Analytical Review
      • Accounts Receivable - Completeness, Write-Offs, and Manual Adjustment Testing
      • Account Receivable - Credit Aging and Approval
      • Accounts Receivable - Credit Limits and Balance Testing
      • Account Reconciliation
      • Automated Sampling
      • Benford's Law
      • CutOff Testing
      • Change Management Review
      • Disbursement Analysis
      • Fictitious Vendor Testing
      • Financial Account Variance Analysis
      • Fixed Assets - Depreciation Recalculation
      • Fixed Assets - Duplicate Identification
      • Fixed Assets - Negative NBV Check
      • Journal Entries - Analytical Review
      • Journal Entries - Anomaly Detection
      • Journal Entries - Approval and Suspicious Posting Testing
      • Journal Entries - Balanced and Suspicious Amount Testing
      • Journal Entries - Duplicates and Sequence Testing
      • Missing Data Check
      • New User Access Testing
      • Numerical Outlier Detection
      • Payroll - Ghost Employees, Analysis, and Duplicates
      • Payroll - Inactivity and Salary Confirmation
      • Procure to Pay - Duplicates and Suspicious Posting Testing
      • Procure to Pay - Mismatched Documents & Vendor Spend
      • Procure to Pay - Payments Remitted to Employees
      • Procure to Pay - Payment Timing and Terms Test
      • Procure to Pay - Vendor Master File Review
      • Risk Scoring
      • Segregation of Duties
      • Terminated User Access Testing
      • Travel & Expense Testing
      • User Access Review
    • 📓Release Notes
  • Workflows
    • 🎨The Canvas
    • 📏Setting Up
    • 👆Drag & Drop
      • 🖱️Click to Add
    • 🧰Tools
    • 🧮Expression Builder
      • Operators
      • Functions
        • Aggregate Functions
          • AVERAGE
          • CORR
          • COUNT
          • COUNTD
          • COUNTBY
          • COUNTIF
          • COUNTIFS
          • COVAR
          • COVARP
          • COVARS
          • MAX
          • MEDIAN
          • MIN
          • MAXBY
          • MINBY
          • PERCENTILE
          • RUNNINGTOTALBY
          • SIGN
          • SIN
          • SQRT
          • SQUARE
          • STDEV
          • STDEVP
          • STDEVS
          • SUM
          • SUMBY
          • SUMIF
          • TAN
          • VAR
          • VARP
          • VARS
          • ZN
        • Conversion Functions
          • TIMESTAMPTODATE
          • TODATE
          • TODECIMAL
          • TOINT
        • Date/Time Functions
          • DATEADD
          • DATEDIF
          • DATENAME
          • DATENORMALIZE
          • DATEPART
          • DATETRUNC
          • DAY
          • DAYS
          • WORKDAYS
          • HOUR
          • ISDATE
          • ISOWEEKDAY
          • ISOWEEK
          • ISOQUARTER
          • ISOYEAR
          • MAKEDATE
          • MAKEDATETIME
          • MINUTE
          • MONTH
          • NOW
          • QUARTER
          • SECOND
          • TODAY
          • WEEK
          • WEEKDAY
          • YEAR
        • Logical Functions
          • AND
          • BETWEEN
          • CASE
          • CHOOSE
          • CONTAINSWITHIN
          • IF
          • IFS
          • IIF
          • IN
          • IFNULL
          • ISBOOLEAN
          • ISDECIMAL
          • ISDURATION
          • ISINTEGER
          • ISNULL
          • ISNUMBER
          • ISSTRING
          • ISUNIQUE
          • NOT
          • NULL
          • OR
          • SWITCH
          • ALL
            • TOSTRING
          • ANY
        • Math Functions
          • ABS
          • ACOS
          • ASIN
          • ATAN
          • ATAN2
          • CEILING
          • COS
          • COT
          • COSEC
          • DEGREES
          • DIV
          • EVEN
          • EXPONENTIAL
          • FILLINFINITY
          • FLOOR
          • HAVERSINE
          • LOG
          • LN
          • ODD
          • MODULO
          • PERCENTILEOFVALUE
          • PERCENTILEVALUE
          • PI
          • POWER
          • RADIANS
          • RANDOM
          • ROUND
          • SEC
        • Table Functions
          • ENCODE
          • INDEX
          • INDEXBY
          • FILLNULL
          • FIRSTBY
          • GENERATEUNIQUEID
          • LASTBY
          • LOOKUP
          • MATCH
          • NTH
          • OFFSET
          • OFFSETBY
          • PREVIOUSVALUE
          • RANK
          • RANKBY
          • RECORDID
          • ROLLINGAVERAGE
          • ROW
          • RUNNINGAVERAGE
          • RUNNINGMAX
          • RUNNINGMIN
          • RUNNINGSTDEV
          • RUNNINGTOTAL
          • WINDOWAVERAGE
          • WINDOWMAX
          • WINDOWMIN
          • WINDOWCOUNT
          • WINDOWSUM
          • SEQUENCE
          • WINDOWMEDIAN
          • WINDOWSTDEV
          • WINDOWSTDEVP
          • WINDOWSTDEVS
          • WINDOWVAR
          • WINDOWVARP
          • WINDOWVARS
          • WINDOWCORR
          • WINDOWCOVAR
          • WINDOWCOVARP
          • WINDOWCOVARS
          • SMOOTHEDAVERAGE
        • Text Functions
          • ASCII
          • CHAR
          • CONCAT
          • CONTAINS
          • ENDSWITH
          • FIND
          • FINDNTH
          • ISEMPTY
          • JSONPARSE
          • LEFT
          • LENGTH
          • LOWER
          • LTRIM
          • MID
          • PROPER
          • RIGHT
          • RTRIM
          • SPACE
          • SPLIT
          • STARTSWITH
          • TRIM
          • SUBSTITUTE
          • UPPER
        • Window Functions
    • 🔗Parameters
      • File Input Parameters
      • Sample Tool Parameters
      • System Parameters
  • Tools
    • 🗃️Import
      • Import File
      • Import From API
      • Import From Integration
        • GitHub
        • Snowflake
      • Import Sample Data
      • New Table
    • ✨Clean
      • Find Replace
      • ParseJSON
      • Sample
      • Text to Columns
      • Validate
    • 💻Code
      • PythonCode
        • Fuzzy Match
    • 🤝Merge
      • Append
      • Join
    • 🧙Transform
      • Edit Columns
      • Add Columns
      • Select Columns
      • Filter
      • Sort
      • Deduplicate
      • Pivot
      • Unpivot
    • 📊Visualize
      • Chart
        • Bar
        • Line
        • Combo
        • Scatter
        • Histogram
        • Box
        • Pie
        • Area
        • Funnel
    • 📬Publish
      • Publish to Toolkit
      • Publish via Email
  • 📚Dictionary
Powered by GitBook
On this page
  • Input, Output
  • Accessing Objects & Parameters
  • Returning Objects
  • Table
  • Chart
  • Available Libraries

Was this helpful?

  1. Tools
  2. Code

PythonCode

Last updated 26 days ago

Was this helpful?

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

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:

Library
Description
Import

Data manipulation

import pandas

API requests

import requests

Numerical and statistical operations

import numpy

URL Encoding/decoding

import urllib

JSON handling

import json

💻
Pandas
Requests
Numpy
URLlib
JSON