Home > OS >  How do I view sheet n in a Pandas dataframe?
How do I view sheet n in a Pandas dataframe?

Time:11-22

I have loaded an Excel file into a pandas dataframe with:

df = pandas.read_excel("file.xlsx")

The file has multiple sheets, but only the first is displayed when I invoke the dataframe name.

How do I view the other sheets?

CodePudding user response:

You can try using pandas ExcelFile

xls = pd.ExcelFile('path_to_file.xls')
df1 = pd.read_excel(xls, 'Sheet1')
df2 = pd.read_excel(xls, 'Sheet2')

CodePudding user response:

import pandas as pd

df = pd.read_excel("file.xlsx", sheet_name = 'sheet1')

  • Related