How to print pandas Dataframe without index

0 votes

I have imported a CSV file in Python using pandas. Now when I try to print it, it displays the contents along with the index. I don’t want to print the index. How can I exclude the index and print only the contents?

This is the code I am using

import pandas as pd
filedata = pd.read_csv(“/home/user/data1”)
print (filedata)

Output:

1 Kia

2 Benz

3 Chevvy

4 Bugatti

5 Ford

6 Fiat
Mar 28, 2019 in Python by John
6,990 views

1 answer to this question.

0 votes

You can print the dataframe without index by converting the dataframe to strong with index as false. Try this:

import pandas as pd
filedata = pd.read_csv(“/home/user/data1”)
print (filedata.tostring(index=False))
answered Mar 28, 2019 by Shri

Related Questions In Python

0 votes
1 answer

How to print the index of a Pandas Dataframe?

You can do this using the code ...READ MORE

answered May 13, 2019 in Python by Usha
22,519 views
0 votes
1 answer

How to append dataframe without index?

You have to use the ignore_index option. ...READ MORE

answered Apr 1, 2019 in Python by Robert
15,347 views
0 votes
1 answer

How to get value in Pandas dataframe using index?

You can use the iloc method to do ...READ MORE

answered Apr 8, 2019 in Python by Rohit
8,360 views
0 votes
1 answer

How to print rows at different locations of pandas dataframe?

Like you are using row slicing, you ...READ MORE

answered May 13, 2019 in Python by Gani
2,165 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,467 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,128 views
+1 vote
3 answers

How to print one pandas column without index?

There is a slight mistake in what ...READ MORE

answered Mar 28, 2019 in Python by Shri
64,368 views
0 votes
1 answer

How to print all the index of Pandas Dataframe?

Try this: print(df.index.values) READ MORE

answered Apr 8, 2019 in Python by Yogi
5,439 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