1

I am trying to delete the first header row of the table which is 'Table 2.......'. original table

I tried the code below

d1t2.columns = d1t2.iloc[0]
d1t2 = data1t2.reindex(d1t2.index.drop(0)).reset_index(drop=True)
d1t2.columns.name = None 
d1t2

But the result is: the second row of the table, which the row of index=0 has been deleted.

1 Answer 1

3

You were close:

d1t2.columns = d1t2.iloc[0]
d1t2.columns.name=None
d1t2.drop(0, axis=0, inplace=True)

However, if you read d1t2 from a file, it would be better to skip the first row.

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.