0

I am using ipython notebook with Python 2.x and I notice that usually there is a difference in how Python outputs if I use print command or do not use it. (Latter works only for last line in the cell)

For instance

df=pd.DataFrame({'A':[1,2,3,4,5,6],'B':list('ABCDEF')})
print df
df

Would give

Output with and without print

I like the second output which is nicely tabulated but it disappears if I use print

How do I get the output with print command with table around it as currently seen in output without print ?

2
  • 1
    This is true on the console as well. It's the difference between the str and repr functions in Python. Commented Mar 8, 2016 at 0:08
  • Thanks @user3697163 for pointing to the previous query. I tried to search before posting but could not find it with keywords I was trying. I was sure this would have been discussed earlier. Commented Mar 8, 2016 at 0:12

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.