0% found this document useful (0 votes)
2 views

PythonCheatSheetPDF

This cheat sheet provides essential Python functions for use in Alteryx, including data input/output methods, package management, and basic Pandas operations. It outlines key commands for reading and writing data, as well as metadata handling and visualization with Matplotlib. Additionally, it includes Jupyter Notebook shortcuts and resources for further assistance with the Python Tool in Alteryx.

Uploaded by

Ramya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

PythonCheatSheetPDF

This cheat sheet provides essential Python functions for use in Alteryx, including data input/output methods, package management, and basic Pandas operations. It outlines key commands for reading and writing data, as well as metadata handling and visualization with Matplotlib. Additionally, it includes Jupyter Notebook shortcuts and resources for further assistance with the Python Tool in Alteryx.

Uploaded by

Ramya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

PYTHON FUNCTIONS IN ALTERYX : CHEAT SHEET

INPUTS AND OUTPUTS PACKAGES AND SCRIPTS PANDAS ESSENTIALS


from ayx import Alteryx import pandas as pd
Alteryx.read("#1")
This essential code will be automatically placed in the first Import pandas package with abbreviation to use
Stream in a connected data input to the Python Tool.
cell of your notebook to import the Alteryx API package. functions commonly written with “pd.”
Creates a Pandas DataFrame.
Package.installPackages() df.head(n) or df.tail(n): display first or last n rows
Alteryx.getIncomingConnectionNames()
To add packages not installed by default. Alteryx must be of DataFrame
Returns a list of all incoming data connections in a list.
in admin mode.
df.info(): index, datatype and memory information
Alteryx.write(df, 1)
Writes Pandas DataFrame out of Python Tool to the Import an Existing Python Script or Jupyter Notebook
Alteryx > Import Script > Choose File > Import df.describe(): summary statistics for numerical
anchor with the number specified.
columns
METADATA Default Packages
df[[column_1, column_2]]: returns selected
The packages loaded by default for the Python Tool are
Alteryx.readMetadata('#1') ayx, geopandas, jupyter, matplotlib, numpy, pandas, columns as a new DataFrame
Read metadata from incoming data stream as requests, scikit-learn, scipy, six, SQLAlchemy, and
dictionary. statsmodels. df.columns = [‘a’, 'b’, ‘c’]: rename all columns

Alteryx.write(df, 1, md) df.rename(columns={‘old_name’ : ‘new_ name’}):


Write out the data with the original metadata. JUPYTER NOTEBOOK SHORTCUTS rename only selected columns

Add metadata for new column: Run an individual cell: Ctrl + Enter df.column_1 = df.column_1.astype(int): convert
md['new_column'] = { Add a cell above current cell: Esc then A column_1’s datatype to integer
'name': ‘New Column Name', Add a cell below current cell: Esc then B
'type': 'String', Delete current cell: Esc then D twice df2 = df[df[column_1] > 3]: make new DataFrame
'length’: (8,) Set cell type as Code: Esc then Y from rows where column_1 value is greater than 3
} Set cell type as Markdown: Esc then M
Split cell in two at cursor location: Ctrl + Shift + _ RESOURCES
MATPLOTLIB ESSENTIALS Comment/uncomment line of code: Ctrl + /
Alteryx.help()
import matplotlib.pyplot as plt Use this function in the Jupyter interface for help.
Import matplotlib package with abbreviation to use INTERFACE TOOLS
functions commonly written with “plt.” Workflow Example
Alteryx.getWorkflowConstant() Click on the Python Tool and then Open Example.
plt.hist(column_1) Retrieve a specific workflow constant. Example:
Make a histogram (bar chart) of values in column_1. Alteryx.getWorkflowConstant("Engine.WorkflowDirectory") Tool Mastery | Python
plt.scatter(column_1, column_2) Alteryx.getWorkflowConstants( ) Python Tool Help Documentation
Make a scatter plot comparing column_1 (x-axis) to Returns a dictionary of the values of all Alteryx workflow
How to Reset the Python Tool to its Original State
column_2 (y-axis). constants.

You might also like