0

How to code in Excel and Tableau using python?

I am trying use python coding to analyse data in excel and Tableau. I do not know how or where to start with.

8th Jul 2021, 2:51 AM
Naveen Kumar
Naveen Kumar - avatar
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.
8th Jul 2021, 8:56 AM
Elvish
Elvish - avatar
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]))
18th Sep 2025, 2:03 PM
Mayank kumar Verma
Mayank kumar Verma - avatar