0

I have a Excel workbook which has 5 sheets containing data. I want each sheet to be a different dataframe.

I tried using the below code for one sheet of my Excel Sheet

df = pd.read_excel("path",sheet_name = ['Product Capacity'])
df

But this returns the sheet as a dictionary of the sheet, not a dataframe.

I need a data frame. Please suggest the code that will return a dataframe

0

1 Answer 1

1

If you want separate dataframes without dictionary, you have to read individual sheets:

with pd.ExcelFile('data.xlsx') as xlsx:
    prod_cap = pd.read_excel(xlsx, sheet_name='Product Capacity')
    load_cap = pd.read_excel(xlsx, sheet_name='Load Capacity')
    # and so on

But you can also load all sheets and use a dict:

dfs = pd.read_excel('data.xlsx', sheet_name=None)
# dfs['Product Capacity']
# dfs['Load Capacity']
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.