Add header row in pandas dataframe while printing

0 votes
Hi. I am new to python and Pandas. I have 3 columns in a csv file. I am trying to read and then print it as a dataframe. The data in the csv file does not has a header but I want to print the header while printing the dataframe. How can I do this?
Jul 5, 2019 in Python by Esha
4,947 views

1 answer to this question.

0 votes

Refer to this code:

import pandas as pd
col_name=['Name', 'Age','Gender']
csv_file=pd.read_csv('<csv filename with path to csv file>', name=col_name)
print(csv_file)
answered Jul 5, 2019 by Suri

Related Questions In Python

–1 vote
1 answer
0 votes
1 answer

Add one row to pandas DataFrame

You can try the following : >>> import ...READ MORE

answered Mar 1, 2019 in Python by SDeb
• 13,250 points
468 views
0 votes
1 answer

Pandas row in printing whole structure instead of value.

Try this code, it should print only ...READ MORE

answered Mar 28, 2019 in Python by Siri
87 views
0 votes
1 answer

How to iterate over row in a Dataframe in Pandas?

Hi, You can use df.iterrows(), it yields both ...READ MORE

answered Jul 18, 2019 in Python by Taj
• 1,060 points
1,305 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 438 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,140 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
6,426 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,145 views
0 votes
1 answer

How to append a row to a Pandas dataframe?

You can use the append method provided by pandas ...READ MORE

answered May 9, 2019 in Python by Raj
975 views
0 votes
1 answer

How to find the sum of rows in Pandas dataframe?

You can use a combination groupby function with the sum() method. ...READ MORE

answered May 9, 2019 in Python by Jisha
2,178 views