January 2019
Beginner
318 pages
8h 23m
English
In this section, we are going to read Excel files using the pandas module. Now, let's look at an example of reading an Excel file.
Create a script called rd_excel_pandas.py and write the following content in it:
import pandas as pdexcel_file = 'sample.xlsx'df = pd.read_excel(excel_file)print(df.head())
Run the preceding script and you will get the following output:
student@ubuntu:~/test$ python3 rd_excel_pandas.py
Following is the output:
OrderDate Region ... Unit Cost Total0 2014-01-09 Central ... 125.00 250.001 6/17/15 Central ... 125.00 625.002 2015-10-09 Central ... 1.29 9.033 11/17/15 Central ... 4.99 54.894 10/31/15 Central ... 1.29 18.06
In the preceding example, we are reading an Excel file using the pandas ...
Read now
Unlock full access