From the course: Python in Excel: Data Outputs in Custom Data Visualizations and Algorithms
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Using the PY Excel function
From the course: Python in Excel: Data Outputs in Custom Data Visualizations and Algorithms
Using the PY Excel function
- [Instructor] To write Python code directly in Excel cell will leverage the PY or PY function, which creates output from running Python code. This function is two parameters, the Python code we want to run in the selected cell and the return type of the Python output. In the intro sheet of our Excel file, let's check out some examples. We'll first type in the PY function into a cell in our workbook where we want to put our Python code. We'll then hit Tab and notice it opens the Python Code Editor. We can also choose to insert Python code directly into a cell through the Python button in the top ribbon's Formula menu options. Alternatively, we can hold down the keys Control + Alt + Shift and P simultaneously to open the Python editor for the selected worksheet cell. We'll then input our Python code into the formula bar that appears. Let's start with a classic first line of programming code by inputting hello world as a text string. Once we finish typing our Python code, to commit it…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Breaking down Excel and Python processes1m 48s
-
(Locked)
Leveraging Power Query6m 32s
-
(Locked)
Using the PY Excel function3m 44s
-
(Locked)
Using the XL Excel function and Python variables4m 23s
-
(Locked)
Determining calculation order4m 31s
-
(Locked)
Importing Python libraries into Excel3m 20s
-
(Locked)
Managing errors4m 14s
-
(Locked)
Working with Python objects7m 3s
-
(Locked)
Transforming DataFrame objects7m 41s
-
(Locked)
Challenge: Creating table objects in Excel2m 15s
-
(Locked)
Solution: Creating table objects in Excel3m 9s
-
-
-
-