Importing sheets from Excel files
In the previous exercises, you saw that the Excel file contains two sheets, '2002' and '2004'.
The next step is to import these.
In this exercise, you'll learn how to import any given sheet of your loaded .xlsx file as a DataFrame. You'll be able to do so by specifying either the sheet's name or its index.
The spreadsheet 'battledeath.xlsx' is already loaded as
xls.
Deze oefening maakt deel uit van de cursus
Introduction to Importing Data in Python
Oefeninstructies
- Load the sheet
'2004'into the DataFramedf1using its name as a string. - Print the head of
df1to the shell. - Load the sheet
2002into the DataFramedf2using its index (0). - Print the head of
df2to the shell.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Load a sheet into a DataFrame by name: df1
df1 = xls.parse(____)
# Print the head of the DataFrame df1
print(____)
# Load a sheet into a DataFrame by index: df2
# Print the head of the DataFrame df2
print(____)