Alteryx Designer Desktop Discussions

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

Executing an Iterative Function in Python

aaronindm
8 - Asteroid

I am trying to pass parameter to, and execute, a function within the Python tool.  It is actually a function within a function.  this is a specialized IRR calculation (it differs from the built in Alteryx IRR calculation).  The code was "converted" from a VB custom Excel function (works fine there)

 

What I don't know is how to properly execute the function.  Seems like Alteryx makes an attempt before erroring out

 

A simplified version is attached

5 REPLIES 5
PhilipMannering
16 - Nebula
16 - Nebula

HI @aaronindm,

 

I'd be lying if I said that I understand what you're doing. But I have got it to run without error. The issue, I think, is that data is read in and out of Atleryx as Pandas DataFrames, therefore you need to a few extra steps to extract the data from the DataFrame before you can use it in your function.

 

Take a look at the attached.

aaronindm
8 - Asteroid

@PhilipMannering Thanks you for the reply but I am not seeing the additional code you added, can you call that out specifically for me?  The Python tool code from the one I uploaded looks to be the same as the one you uploaded.

 

There is likely some nuance that I am missing

PhilipMannering
16 - Nebula
16 - Nebula

Hmm.... so this puzzled me a bit, but I think what has happened is that both workflows are pointing to the same folder for the the .ipynb file (the jupyter notebook). So updating the python tool in one "Becker_IRR_4.yxmd" will also change the python tool in "python tool troubleshooting.yxmd". So it looks like both are the same.

 

But what I changed was the comments, the location of data after Alteryx.read() and adding the result to a DataFrame before writing out in the final cell,

PhilipMannering_0-1617034552823.png

Now you get an output (0.003044), whereas before you got an error.

 

PhilipMannering
16 - Nebula
16 - Nebula

Hey @aaronindm ,

 

See the Python code for multiple rows attached.

aaronindm
8 - Asteroid

Wow thank you so much for this - works like a charm!

Polls
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Labels