Python tool in Alteryx

Python tool in alteryx is a great way to incorporate python code into the alteryx workflow. It gives us another distinct feature which one doesn't think of, when one starts making workflows using the most used tools i.e.  the frequently used tools like the one we can encounter in "In/Out", "Preparation", "Join", "Parse" and "Transform".

 

Let's get into the details of python tool in alteryx




This is how python tool look like in Alteryx. It requires one input (not mandatory to provide) and we have five output terminals, through which we can have a look at 5 different dataframes (it’s just table in python language)

We can use the python tool in two different modes

1)      Interactive mode : When the workflow is run, Alteryx will print messages within the Jupyter notebook and refresh the data available to the notebook. This is helpful for developing code but less efficient.  Use Interactive mode to view inline errors and charts.  

2)      Production mode : Used to optimize speed and efficiency when you don’t need to inline error messaging.

Input data

Input data is read as pandas dataframe (pandas is one of the various libraries that python has). The input data is read by python tool using the command

                                                                                df = Alteryx.read("#1")

where df is the name of the dataframe, which you can chose by yourself.

Analysis

Perform your analysis on the pandas dataframe. Create new columns and you can delete redundant columns. You might have to install some libraries and modules depending upon the nature of the analysis, you’re going to perform.  For example, using the code below, I’m installing the  Python library which allows you to encode and decode JSON Web Tokens (JWT)

                                                                                pip install pyjwt

Features

You can also directly import a script (jupyter notebook file i.e. .ipynb file). Jupyter Notebook (formerly IPython Notebooks) is a web-based interactive computational environment for creating notebook documents.

There are some tools present in the Alteryx which don’t mandatorily need an input to provide the output and python tool is one of them. 




You can  get more information about Jupyter notebook here

https://jupyter.org/

Output

The output can be written to any of the five output terminals that python tool provides. The command to write the output in the third output terminal is as shown

Alteryx.write(df, 3)

Where df is the name of the dataframe.

This is basically everything you need to know to get going with the python tool. Of course there are more advanced features which you’ll eventually come across, when you start working with it.

One of the mantra to get familiarize with the new tools is to go through the example given in the alteryx. On the right hand side upper corner, you can search for the tool and click on example for the tool you want to learn more about and go through it. This is a great way to see different use cases of a tool and then you can make a strategy for how you can use the tool for your needs.




Thanks for reading    

 Until we meet again

Comments

Popular posts from this blog

Alteryx tool