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, 2019 in Python by Raj
9,090 views

1 answer to this question.

+1 vote

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, 2019 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
• 57,550 points
907 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, 2019 in Python by Suri
4,570 views
0 votes
0 answers

How to write df to excel without attribute error, and how to add 2 header columns (1 header, 1 units)

Hi, I am very new to Python ...READ MORE

Jun 3 in Python by Edureka
• 120 points

edited Jun 5 by Gitika 249 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
• 57,550 points
6,736 views
0 votes
1 answer

How to rename columns in pandas (Python)?

You can use the rename function in ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 8 by MD 395 views
0 votes
1 answer

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

The major difference is "size" includes NaN values, ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 8 by Gitika 1,066 views
0 votes
2 answers

Replacing a row in pandas data.frame

key error. I love python READ MORE

answered Feb 18, 2019 in Data Analytics by anonymous
5,901 views
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,560 points
3,025 views
0 votes
2 answers

How to read Pandas csv file with no header?

Use this logic, if header is present ...READ MORE

answered Mar 14 in Python by Shahabuddin
• 140 points
16,766 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, 2019 in Python by TIna
422 views