Pandas df header on 2 row

0 votes

Hi. I have a pandas dataframe that has index on the second row. I want it to ignore the 1st row and consider 2nd as index. How can I do?

Apr 3 in Python by Raj
668 views

1 answer to this question.

0 votes

By default when you import a file, pandas considers the first row as the header i.e., index=0. To consider 2nd row as index, you will have to change this index to 1. Refer to the below code:

dbfile = pd.read_csv('Diabetes.csv', header=1)
answered Apr 3 by Yogi

Related Questions In Python

0 votes
1 answer

Start an iteration on first row of a group Pandas

For anyone needing this information in the ...READ MORE

answered Sep 6, 2018 in Python by Priyaj
• 56,520 points
159 views
0 votes
1 answer

Add header row in pandas dataframe while printing

Refer to this code: import pandas as pd col_name=['Name', ...READ MORE

answered Jul 5 in Python by Suri
200 views
0 votes
1 answer

1 Year Rolling mean pandas on column date

I believe this should work for you: # ...READ MORE

answered Sep 6, 2018 in Python by Priyaj
• 56,520 points
2,299 views
0 votes
1 answer

Pandas DataFrames in a loop, df.to_csv()

can you try something like this? not ...READ MORE

answered Sep 25, 2018 in Python by Priyaj
• 56,520 points
756 views
0 votes
1 answer

How to rename columns in pandas (Python)?

It is easy by just adding ".columns" ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,700 points
99 views
0 votes
1 answer

What is the Difference in Size and Count in pandas (python)?

The major difference is size includes NaN ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,700 points
703 views
0 votes
2 answers
0 votes
1 answer

Converting a pandas data-frame to a dictionary

Emp_dict=Employee.to_dict('records') You can directly use the 'to_dict()' function ...READ MORE

answered May 23, 2018 in Data Analytics by Bharani
• 4,550 points
1,309 views
0 votes
1 answer

How to read Pandas csv file with no header?

You can set the header option to ...READ MORE

answered Apr 3 in Python by Shri
427 views
0 votes
1 answer

How to print just one column in pandas?

You can use the header to print ...READ MORE

answered Apr 3 in Python by TIna
56 views