This post has already been read 592 times!
Excel files can be read using the Python module Pandas. In this article we will read excel files using Pandas.
Data Analysis in Python with Pandas
Read Excel column names
We import the pandas module, including ExcelFile. The method read_excel() reads the data into a Pandas Data Frame, where the first parameter is the filename and the second parameter is the sheet.
The list of columns will be called df.columns.
Using the data frame, we can get all the rows below an entire column as a list. To get such a list, simply use the column header
Read Excel data
We start with a simple Excel file, a subset of the Iris dataset.
To iterate over the list we can use a loop:
We can save an entire column into a list:
We can simply take entire columns from an excel sheet: