user18317706
user18317706

Reputation:

Pandas: How do I delete first two rows of headers?

I'm using an excel file and would like to drop first two rows of headers that has 3 rows of headers.

Current File Example:

    Type1, Type2, Type3, Type4
    SubType1, SubType2, SubType3, SubType4
    SubSubType1-3,,,SubSubType4
0   Blah, Blah1, Blah2, Blah4
1
2

After dropping two headers:

    SubSubType1-3,,,SubSubType4
0   Blah, Blah1, Blah2, Blah4
1
2

I know there are several ways to drop rows using index but I could not find a way to drop first two rows of headers in multiple-header data.

Would appreciate any help.

Upvotes: 1

Views: 1299

Answers (1)

Use header parameter with a value = 2.

data = pd.read_csv("file_name.csv", header=2)

Upvotes: 2

Related Questions