Need help printing a Pandas Dataframe without the index in Python

0 votes

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 in Python by Anirudh
• 2,050 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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 by Nymeria
• 3,500 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
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
0 votes
1 answer
0 votes
1 answer
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 in Python by Nymeria
• 3,500 points
0 votes
1 answer
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,500 points
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 in Python by Nymeria
• 3,500 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.