Reading and writing data in Excel format

Pandas supports reading data in Excel 2003 and newer formats, using the pd.read_excel() function or via the ExcelFile class. Internally, both techniques use either the XLRD or OpenPyXL packages, so you will need to ensure that one of them is installed in your Python environment.

For demonstration, a data/stocks.xlsx file is provided with the sample data. If you open it in Excel, you will see something similar to what is shown in the following screenshot:

The workbook contains two sheets, msft and aapl, which hold the stock data for each respective stock.

The following then reads the data/stocks.xlsx ...

Get Learning pandas - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.