0

I have a xlsx file which has headers in column A and values in columns B through Z. How do I use pandas to read the excel file so that it reads the column names from column A and fills those columns with values from columns B through Z.

Right now when I try to read the excel file it uses the top row value in columns A through Z as column names and uses the values in row second and on for filling the columns.

1 Answer 1

2

you can do it this way:

In [8]: df = pd.read_excel(fn, header=None, index_col=0).T

In [9]: df
Out[9]:
0  col1  col2  col3   col4
1     1    10   100   1000
2    11   101  1001  10001

Source Excel file:

enter image description here

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.