tableau / TabPy

Execute Python code on the fly and display results in Tableau visualizations:
https://tableau.github.io/TabPy/
MIT License
1.56k stars 598 forks source link

TabPy: Python codes failed with error "unsupported operand type(s) for /: 'NoneType' and 'int" #338

Closed feyayang closed 4 years ago

feyayang commented 5 years ago

Environment information:

Describe the issue An error occurred while communicating with the External Service. Error processing script TypeError : unsupported operand type(s) for /: 'NoneType' and 'int' image

Here is the script:

round(SCRIPT_REAL(' from scipy.stats import ttest_ind import numpy as np

result = ttest_ind(_arg1, _arg2) return result[1] ', AVG([Score]),LOOKUP(AVG([Score]),-1)))

I tried with many methods and searched for many related resources but still failed. Here are some methods I tried:

  1. filter on "Score" to remove null values
  2. tried with different table computations
0golovatyi commented 5 years ago

@Cindy1122334455 It looks like there's some problem with data sent to the Python script (Score field). Check with TabPy logs to see where exactly the failure happens.

0golovatyi commented 5 years ago

@Cindy1122334455 Here are similar issues people had in the past, maybe some of those are useful for you:

feyayang commented 5 years ago

@0golovatyi Thank you for help and sorry for the late reply. I did researches on the similar issues you provided but that still did not work for me. I think that I might need to create a function so that I can perform the calculation of Two-sample T-test with TabPy which is so annoying that I cannot use the statistical package scipy when I have a chance to connect Python with tableau via TabPy. Maybe TabPy works well for granular data but not work for limited aggregated data on the tableau worksheet.

0golovatyi commented 5 years ago

@Cindy1122334455 Do you see anything in TabPy logs which may help you to narrow down for where to look to fix the failure?

feyayang commented 5 years ago

Thanks @0golovatyi for coming back to me. I checked with the error information in the log. I think there might be some null values in one of the input variables so that makes sense that "Nonetype" cannot add with "int" type. However, it is so strange that the I still ran into such error even though I filtered the corresponding data field to only contain non-null values.

0golovatyi commented 5 years ago

@Cindy1122334455 I can suggest to prove the issue is in (or not in) Python script invoked from Tableau try it with a small dataset.

FrankHeee commented 5 years ago

from the Tableau side, the AVG(score) might be a data set according to your demensions posted on your table, but the second parameter(arg2,LOOKUP(AVG([Score]),-1)) you provided, it's obviously just one number. Generally, u will need provide either 2 arrays or 2 single numbers, but not to mix them.

0golovatyi commented 5 years ago

@feyayang Were you able to resolve the issue?