0% found this document useful (0 votes)
7 views3 pages

Reading Excel Files with Pandas

This document shows how to use Pandas to read Excel files into DataFrames. It imports Pandas and NumPy, installs the xlrd and openpyxl libraries for reading Excel files, demonstrates using read_excel() to load a sheet from an Excel file into a DataFrame, and shows how to read multiple sheets from an Excel file using a with statement and ExcelFile object.

Uploaded by

sandeep
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Reading Excel Files with Pandas

This document shows how to use Pandas to read Excel files into DataFrames. It imports Pandas and NumPy, installs the xlrd and openpyxl libraries for reading Excel files, demonstrates using read_excel() to load a sheet from an Excel file into a DataFrame, and shows how to read multiple sheets from an Excel file using a with statement and ExcelFile object.

Uploaded by

sandeep
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

In [1]:

import pandas as pd
import numpy as np
from pandas import Series, DataFrame
In [ ]:
# xlrd, openpyxl
In [2]:
# conda install xlrd
# conda install openpyxl
In [ ]:
# read_excel()
In [3]:
xl = pd.read_excel('[Link]', sheetname='Sheet1')
In [4]:
xl

Out[4]:
In [5]:
x = [Link]('excel_example.xlsx')
In [6]:
xl = pd.read_excel(x, 'Sheet1')
In [7]:
Xl

Out[7]:
In [8]:
x2 = pd.read_excel(x, 'Sheet2')
In [9]:
x2
Out[9]:

In [ ]:
# with as xx
In [10]:
with [Link]('excel_example.xlsx') as xlsx:
sheet1 = pd.read_excel(xlsx, 'Sheet1')
sheet2 = pd.read_excel(xlsx, 'Sheet2')
In [11]:
sheet1
Out[11]:
In [12]:

You might also like