Need help printing a Pandas Dataframe without the index in Python

–1 vote

Hi all,

My requirement is simple - I just want to print a Pandas dataframe as a whole. BUT, I do not wish to print the index associated with it. 

It is just that I want to print one column, let's say time and not date inclusive.

To give you better clarity, this is how my dataframe looks like at the moment:

   User ID           Enter Time   Activity Number
0      567  2014-05-06 00:09:00              777
1      567  2014-05-06 00:18:00               674
2      567  2014-05-06 00:49:00              4567

I want to print this as follows:

User ID   Enter Time   Activity Number
567         00:09:00              777
567         00:18:00              647
567         00:49:00              4567

How do I go about doing this? Cheers!

Jan 16, 2019 in Python by Anirudh
• 2,090 points
3,117 views

1 answer to this question.

0 votes

Hi, the answer is a very simple and short one.

All you need do is this:

print df.to_string(index=False)

If this doesn't work for you, then you can go ahead and use this too:

print(df.to_csv(columns=['A', 'B', 'C'], sep='\t', index=False))

Basically, it depends on a string/JSON to be printed or if you are looking for serialization of data as well.

Hope this helps!

answered Jan 16, 2019 by Nymeria
• 3,560 points

Related Questions In Python

0 votes
1 answer

Need help writing a dataframe into a csv with the help of a loop

Using the following logic you can arrive ...READ MORE

answered Apr 17, 2018 in Python by anonymous
3,381 views
0 votes
2 answers

Finding the index of a character in python string

You can use word.find('o') as well to ...READ MORE

answered Jun 1, 2018 in Python by george
• 200 points
1,561 views
0 votes
1 answer
0 votes
1 answer

Need help checking the validity of an image file in Python

I went through the Python documentation and ...READ MORE

answered Jan 18, 2019 in Python by Nymeria
• 3,560 points
2,294 views
0 votes
1 answer
0 votes
1 answer

Need help with making use of Pluck in Python

Hi, good question. Easy solution to be ...READ MORE

answered Jan 24, 2019 in Python by Nymeria
• 3,560 points
1,709 views
0 votes
1 answer

Need help using Joins in Pandas using Python

Hi, there is one scenario where the ...READ MORE

answered Jan 24, 2019 in Python by Nymeria
• 3,560 points
706 views
0 votes
1 answer

How to convert a Pandas GroupBy object to DataFrame in Python

g1 here is a DataFrame. It has a hierarchical index, ...READ MORE

answered Nov 12, 2018 in Python by Nymeria
• 3,560 points
34,454 views
0 votes
1 answer

Need help extracting a schema to make use for an avro file in Python

Hi, nice question. So what I daily use ...READ MORE

answered Jan 10, 2019 in Python by Nymeria
• 3,560 points
4,979 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