I am trying to use scipy.stats.fisher_exact scipy.stats.fisher_exact — SciPy v1.4.1 Reference Guide in a Tableau workbook but I am getting an odd error (only when I try to pass in arguments that are calculations from Tableau-- it works when I pass just raw integers.)
So this works: e.g.:
SCRIPT_REAL(
"
import scipy.stats as stats
oddsratio, pvalue = stats.fisher_exact(([[8, 2], [1, 5]]))
return pvalue
"
,sum([Profit])
,sum([Profit])
,sum([Profit])
,sum([Profit])
)
But, if I actually try to pass aggregate measures (in this example sum([Profit]) into the table, I get this error
"Error processing script
ValueError : The input `table` must be of shape (2, 2)."
e.g.
SCRIPT_REAL(
"
import scipy.stats as stats
oddsratio, pvalue = stats.fisher_exact(([[_arg1, _arg2], [_arg3, _arg4]]))
return pvalue
"
,sum([Profit])
,sum([Profit])
,sum([Profit])
,sum([Profit])
)
Using just the Sample Super Store data source.
For some reason the arguments here are passing as an array of size 1 for each individual arg. Accessing the first index of each argument fixes this. For example using _arg1[0] as opposed to _arg1.
Become a Viz Whiz on the Forums!
Support the Community and master Tableau.