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 XL Excel function and Python variables
From the course: Python in Excel: Data Outputs in Custom Data Visualizations and Algorithms
Using the XL Excel function and Python variables
- [Instructor] If we want to use Excel objects like worksheet cells within our Python in Excel code blocks, we can use the Excel function within the Python function PY to reference these input parameters. Within our Python code in Excel, we can set variables in the same way we would for Python code run in another IDE. In our first line of code, let's set A = 1. In the second line of code we'll create a new Python variable X and set it equal to A + 1. The output as expected, returns two here. We can also use the Python code variables in other Excel cells. In the third row of our results table where it says X squared, we'll again use the Python function where we'll reference the X variable. Notice, we see it appear from the dropdown menu as we type in the variable name, we can then choose Tab to select it and we'll confirm these results. Now let's square the output. We'll use the double asterisk followed by two, and we'll hit Ctrl + Enter again to update our formula. As we expect, this…
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
-
-
-
-