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 4, 2019 in Python by Raj
27,817 views

1 answer to this question.

+2 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 4, 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
• 58,090 points
2,084 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
7,350 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, 2020 in Python by Edureka
• 120 points

edited Jun 5, 2020 by Gitika 9,614 views
0 votes
2 answers

Deleting DataFrame row in Pandas based on column value

Pandas provide data analysts a way to ...READ MORE

answered Jan 4, 2021 in Python by Nikita
2,070 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, 2020 by MD 1,679 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, 2020 by Gitika 2,523 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
13,047 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,660 points
4,353 views
0 votes
5 answers

How to read Pandas csv file with no header?

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

answered Mar 14, 2020 in Python by Shahabuddin
• 160 points
217,854 views
0 votes
1 answer

How to print just one column in pandas?

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

answered Apr 4, 2019 in Python by TIna
10,355 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP