Chapter 7Working with Columns
While dataframes are the fundamental unit of analysis when using Python in Excel, you typically spend more time working with individual columns rather than entire tables of data.
This chapter teaches you the fundamentals of working with pandas Series objects (i.e., columns), including the differences between numeric, string, and datetime columns.
These fundamentals are required for the next two chapters, which use a hypothetical data analysis example.
7.1 EXPLORING COLUMNS
This chapter’s Python code again uses the data from the PythonInExcelStepByStep.xlsx workbook. It’s highly recommended that you download the workbook and follow along by writing all the code.
As the amount of Python code in your workbook grows, you will see that it takes longer for all the code to run. Because Python in Excel calculates formulas in the left-most worksheet first, you can reorder the worksheets so that the Ch 7 Python Code worksheet is the farthest left if you like.
The first step is to load the dataframes you need from the tables stored in the workbook. The Python Editor provides the option of only looking at a specific worksheet’s Python formulas, as demonstrated in Figure 7.1.

Figure 7-1: Selecting the Chapter 7 Worksheet.
As you’ve seen in previous chapters, I show you the code and output in textual form when screenshots of the Python Editor won’t add that ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access