A complete Python tool in Alteryx - Pascal's triangle
By DavidSM on August 13, 2018
After a couple of posts
(I
&
II)
getting my feet wet with the Python SDK
module
for
Alteryx
I finally get to build a tool that actually uses some code:
The Pascal’s Triangle generator
Following the original
recipe,
I duplicated a sample folder, renamed the files, removed most of the
superfluous code, added the pieces I needed and, finally, connected my
code with the AyxPlugin. All so that I can generate my own Pascal’s
Triangles with a
single tool.
The main difference with the previous tool is that the code references
two python libraries that are not part of the miniconda distribution
that comes with Alteryx:
On hindsight, this is an overkill and I could/should have just written a
self-contained
implementation.
BUT I did want to play with importing packages and virtual
environments so… The installer is available
here. Install
it by double clicking on it, it will appear in the “Laboratory” tools.
Unzip the .yxi to explore the files.
I first wrote a working example using Jupyter:
Then I migrated that code into the PascalTriangleEngine.py
Import libraries.
Bring the Pascal Function.
Update pi_push_all_records.
Import libraries
Pascal Function
Pi_push_all
Finally, I made sure to follow the steps detailed in the official
documentation
to obtain the installer and proper dependencies:
Create a virtual environment.
Install packages in the virtual environment.
Create the requirements.txt file using pip freeze.
Create the installer .yxi.
Virtual environment
Packages
Requirements
Thanks for reading!
Find this and other python tools for Alteryx in my repo .