2 Answers
0
It seems that Excel only supports VBA so you cannot use python there.
However, you can export .xls to .csv and apply the Pandas library, then open your result in Excel and turn it into .xls again.
0
tep 1: Use Python with Excel
You can use the pandas library to read and analyze Excel data.
Install libraries:
pip install pandas openpyxl
Example code:
import pandas as pd
# Load Excel file
df = pd.read_excel("data.xlsx")
# Basic analysis
print(df.head()) # first 5 rows
print(df.describe()) # summary stats
You can clean, filter, and analyze data directly in Python, then save it back to Excel using df.to_excel("output.xlsx").
Step 2: Use Python with Tableau
Tableau doesnât run Python directly but connects to it using TabPy (Tableau Python Server).
Install TabPy:
pip install tabpy
tabpy
(This starts a local Python server.)
In Tableau:
Go to Help â Settings and Performance â Manage External Service Connection
Connect Tableau to TabPy (default: localhost:9004).
Now, in Tableau calculated fields, you can use Python code like:
SCRIPT_REAL("return _arg1 + _arg2", SUM([Sales]), SUM([Profit]))