Pandas: Reading .xlsx or .xls Excel Files

To read an Excel file using Python pandas we can make use of the read_excel() method, this will return the Excel data in tabular form as a dataframe.


Microsoft Excel file: data.xlsx

Excel xlsx file to be read using Python Pandas

Example:

import pandas as pd

excel_file = 'data.xlsx'

dataframe = pd.read_excel(excel_file)
print(dataframe.head())
Output:
% python3 example.py

        Date  Temp
0 2023-01-01    22
1 2023-02-01    22
2 2023-03-01    21
3 2023-04-01    20
4 2023-05-01    19

Do checkout the official pandas documentation on read_excel method: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_excel.html

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!