Loading an Excel Dataset into a DataFrame
Learn to import an Excel dataset into a DataFrame.
We'll cover the following...
Loading Excel files
Sometimes we can store data inside other data sources, such as Excel files. We can also store this data online and access it through a URL.
To import such data, we use the read_excel()
pandas function.
Press + to interact
import pandas as pdexcel_df = pd.read_excel("https://github.com/CourseMaterial/DataWrangling/blob/main/housing.xlsx?raw=true")print(excel_df.tail())
Let’s review the code line by line:
Line 1: We import the pandas library.
Line 2: We use the
read_excel()
function to read the Excel file with the URLhttps://bit.ly/housingexcelds
and store it inexcel_df
.Line 3: We print the last five records of the DataFrame using the
tail()
function.
From the output, we observe the last five records of the Excel dataset in the output. As an alternative to the head()
function, the tail()
...