0

I have an excel sheet that I am trying to read into as a dataframe. The sheet has multiple header rows that each can have varying amount of columns. Some of the columns are similar, but no always. Is there a way I can split the rows into separate dataframes?

The data for example would be:

A B C D
1 1 1 1
2 2 2 2
A B C D E
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
A B C
1 1 1

The ideal output would be three separate dataframes which their respective rows and column headers.

1
  • Do you know the number of rows after which to split? Commented Nov 2, 2018 at 18:52

1 Answer 1

1

.read_excel has header, skiprows and skipfooter arguments that let you do this, provided that you can detect or know ahead of time what row each header is on. With these and usecols you can define any "window" on the sheet as your df. Combining multiple windows can then be accomplished with concat, merge, append, and join, per usual.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.