Read Data from Excel file in Pandas
We can use the read_excel function to read the data from the Excel file and converts it into a DataFrame. To read the data from the Excel file in pandas using the below syntax:
Syntax pd.read_excel(“file_name.xlsx”)
Note: In this exercise, we are using the datasource sales.xlsx. You can download the datasource and use for the transformation.
Example: Here, we are reading the file named sales.xlsx and then show the dataframe in the output.
Python
# Import pandas package import pandas as pd # Read data from excel file mydata=pd.read_excel("sales.xlsx") mydata
The output of the above code is shown below:
