Pragyan Bezbaruah
Pragyan Bezbaruah

Reputation: 183

TabPy - No return value

I am working in TabPy inside Tableau and want to perform normal statistical calculations.

I am stuck with Cp calculation. Here is the code that I wrote -

    SCRIPT_REAL("

import pandas as pd
import numpy as np
from scipy import stats


# Calculate Cp

def Cp(list,_arg2,_arg3):
   arr = np.array(list)
   arr = arr.ravel()
   sigma = np.std(arr)
   Cp = float(_arg2 - _arg3) / (6*sigma)
   return Cp


",FLOAT([USL - Param]), FLOAT([LSL - Param]))

The error that I am getting is -

No Return Value

although I am clearly returning Cp. What could be the issue?

Please help.

Upvotes: 2

Views: 627

Answers (1)

PyKa
PyKa

Reputation: 113

Something like the below would solve some of the issues you're seeing.

I haven't checked the validity of your Cp function, and whether this would work with lists or single values.

SCRIPT_REAL("

import pandas as pd
import numpy as np
from scipy import stats


# Define Cp

def Cp(argu_1,argu_2):
   arr = np.array(list)
   arr = arr.ravel()
   sigma = np.std(arr)
   Cp_value = float(argu_1 - argu_2) / (6*sigma)
   return Cp_value

# Call function with variables from Tableau, and return the Cp_value
return Cp(<Argument 1>, <Argument 2>)

",FLOAT([USL - Param]), FLOAT([LSL - Param]))

Upvotes: 1

Related Questions