-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Python Business Intelligence Cookbook
By :
While many people will tell you to get data out of Excel as quickly as you can, Pandas provides a function to import data directly from Excel files. This saves you the time of converting the file.
To create a Pandas DataFrame from an Excel file, first import the Python libraries that you need:
import pandas as pd
Next, define a variable for the accidents data file and enter the full path to the data file:
customer_data_file = 'customer_data.xlsx'
After that, create a DataFrame from the Excel file using the read_excel method provided by Pandas, as follows:
customers = pd.read_excel(customer_data_file, sheetname=0, header=0, index_col=False, keep_default_na=True )
Finally, use the head() command on the DataFrame to see the top five rows of data:
customers.head()

After importing Pandas and creating a variable from the path to our Excel file, we use the read_excel() function to create a DataFrame from the spreadsheet. The first...
Change the font size
Change margin width
Change background colour