Why do we need calculations in Tableau? They are essential when the source data lacks the necessary information for visualization but can be derived through calculations.
Python excels in data processing and calculations but falls short in visualization. Therefore, it often makes sense to handle pre-processing in Python and then use Tableau for visualization.
Tableau also has limitations with table calculations. In one of our projects, we had to calculate ranks between columns in Python and then integrate them into Tableau Prep. Additionally, many advanced types of analysis, such as log-linear models, are not feasible in Tableau.
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
By clicking the button, you agree to the processing of personal data.
We use it to stay connected. Read more