1 Reply Latest reply on Jan 3, 2020 3:41 PM by James Morris

    Python Table Input Error with scipy Fishers Exact Test

    Kate Bulger

      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.