Python Tool Output is different to print statement
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I am having an issue with the python tool. I create a dataframe (called df_LS in the picture below), which I print to screen. As you can see from the message in the python tool, it prints the following:
Score Variables 0 0.078739 Sepal_length 1 0.182821 Sepal_width 2 0.020822 Petal_length 3 0.025965 Petal_width
 However the output from the connection data 1, shows up as follows:
Score Variables
0.078739 Sepal_length
-0.589666 Sepal_width
0.033873 Petal_length
0.001242 Petal_width
Any ideas as to what is happening between the "print(df_LS)" statement and the "Alteryx.write(df_LS,1)" statement?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Edit: I see now that you're referring to the value differences.
Is there any chance the calculations are being performed on difference data? It looks like this is a part of a macro, when you run the code in the Python tool and run the workflow, the workflow could be inputting and executing on different observations. Are you running this macro on its own, or as a part of a larger workflow when you notice this discrepancy?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
As this is still in testing mode, I'm running this macro on its own and not as part of a larger workflow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
As a temporary solution to this, i limit all the floating number columns in the dataframe to 10 decimal places. So for a dataframe called df with one floating number column called "num_col", i perform the following operation in python before writing output to Alteryx:
df["num_col"] = df["num_col"].round(10)
This appears to work, but I'm not yet sure what the underlying issue is.
