Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Kertosis and Skewness

SteveP
7 - Meteor

Other than going to the raw math, anyone figure out how to obtain Kertosis and Skewness measures of a univariate distribution? Macro?

5 REPLIES 5
jdunkerley79
ACE Emeritus
ACE Emeritus

Easiest and quickest way I can think of is to use Python:

 

First get packages:

from ayx import Package
Package.installPackages(['pandas','scipy'])

Next:

from ayx import Alteryx
import scipy.stats
import pandas as pd
a = Alteryx.read('#1')
kurt = scipy.stats.kurtosis(a['Field1'])
skew = scipy.stats.skew(a['Field1'])
d = {'kurt': [kurt], 'skew': [skew]}
df = pd.DataFrame(data=d)
Alteryx.write(df,1)

Simple workflow using this attached.

SteveP
7 - Meteor

Good idea - now to figure out Python. I see a few Python help's in the community so I'll check them out. 

Thanks!

marca_at_cue
7 - Meteor

Can you help me modify the Python code to pass in another field to subgroup by when doing the kurtosis and skew calculations?  Output would be 1 row per subgroup_value, with 3 fields in each row: subgroup_value, kurtosis, skew.

SteveP
7 - Meteor

Super - worked flawlessly! Thanks!

LipkeJK
5 - Atom

Has anyone experienced error messages when using a python tool in a macro?  I'm trying to calculate the Skew for each product.  The python script in this thread works when I run it by itself, but I'm running into a roadblock when applying it to a macro.  

 

Thanks!

 

Jon

Labels
Top Solution Authors