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

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…

Contents