Reading and writing data with Excel files
Excel files seem to be ubiquitous in organizations and knowing how to work with them will help us extract more data for analysis. There are a few packages in Python for working with Excel files:
pandas
openpyxl
(for.xlsx
files, also used by pandas)xlrd
andxlwt
(for.xls
files)- and more
For most Excel data wrangling situations, pandas
does everything we need.
Using pandas for wrangling Excel files
We need to ensure that pandas
is installed with conda or pip, and also install openpyxl
for reading Excel files: conda install -c conda-forge openpyxl -y
. Then we can open Excel files with the pd.read_excel()
function.
We will analyze some Excel files from the Midcontinent Independent System Operator (MISO) organization, which provides electricity to large parts of the US and Canada. In this section, imagine you are working for Dynasty Power Inc. as a junior power analyst analyzing energy markets...