Why do we need calculations in Tableau? They help when the source does not contain the data necessary for visualization but can be obtained using calculations.
Python is more versatile in data processing and calculations but worse for visualization. So there are several tasks for which it makes sense to do pre-processing in Python and then visualize in a Tableau.
Tableau is also limited in table calculations. For one of the projects, we had to eventually calculate the ranks between the columns in Python, clinging it to the Prep. Besides, many advanced types of analysis in the scoreboard are not possible, for example, log-linear.
The advantages of Python for BI cases
TabPy installation & setup
python –m venv ‘name of the virtual environment’
For example: python –m venv myenv
Activation: myenv\Scripts\activate
Deactivation: deactivate
TabPy module connection
Python virtual environment
x_full = pd.DataFrame(_arg1, _arg2)
p = regr.predict(x)
SCRIPT_INT for integer data (1, 2, 3, 5, 8);
SCRIPT_REAL for floating-point data (3,14, 2,72, 6,07);
SCRIPT_STR for categorical data (men/women);
SCRIPT_BOOL for boolean data (True/False)
Let's build a regression Model!
x = pd.DataFrame(_arg4, _arg5)
y = _arg3
regr = LinearRegression()
regr.fit(x,y)
SCRIPT_REAL(“PYTHON CODE…”,
SUM([Sales]) # forecasting
SUM([Discount]) # forecasting
SUM([filtered Profit]) # training
SUM([filtered Sales]) # training
SUM([filtered Discount])) # training
Script execution error
Explore our possibilities
By clicking the button, you agree to the processing of personal data. We use it to stay connected. Read more