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
29,595 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,020 points
2,287 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,627 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 10,259 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,458 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 2,088 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,924 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,792 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,600 views
+1 vote
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
231,940 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,874 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