4

In Pandas 0.18.1, say I have a dataframe like so:

df = pd.DataFrame(np.random.randn(100,200))
df.head()

    0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  

What if I wanted to view this vertically like so:

0 1 2 3 4 5 
6 7 8 9 10 11

the docs point to:

pd.set_option('expand_frame_repr', True)

df

0         1         2         3         4         5         6  \
0 -1.039575  0.271860 -0.424972  0.567020  0.276232 -1.087401 -0.673690   
1  0.404705  0.577046 -1.715002 -1.039268 -0.370647 -1.157892 -1.344312   
2  1.643563 -1.469388  0.357021 -0.674600 -1.776904 -0.968914 -1.294524   
3 -0.013960 -0.362543 -0.006154 -0.923061  0.895717  0.805244 -1.206412   
4 -1.170299 -0.226169  0.410835  0.813850  0.132003 -0.827317 -0.076467   

      7         8         9  
0  0.113648 -1.478427  0.524988  
1  0.844885  1.075770 -0.109050  
2  0.413738  0.276662 -0.472035  
3  2.565646  1.431256  1.340309  
4 -1.187678  1.130127 -1.436737  

Yet I can't seem to get that same result; what am I missing?

Previous questions seem to revolve around viewing all rows within the slider (pd.set_option('display.max_columns', None) sort of thing)

4
  • Could you transpose it or do you want to wrap the columns? Commented Feb 8, 2017 at 17:19
  • I just want to wrap it basically; the way 'expand_frame_repr' seems to do it in the docs Commented Feb 8, 2017 at 17:25
  • You could try pd.reset_option('all'), then set all other. It sets all options default. Commented Feb 8, 2017 at 17:43
  • same result after a pd.reset_option('all') Commented Feb 8, 2017 at 18:31

2 Answers 2

14

If you want to see just a few records, try this.

df.head(3).transpose()
Sign up to request clarification or add additional context in comments.

Comments

5

Try this:

import pandas as pd
pd.set_option('expand_frame_repr', True)
pd.set_option("display.max_rows", 999)
pd.set_option('max_colwidth',100)

print(df)

2 Comments

If you have IPython.display import display imported it will not work by just calling it you will print into a typical dataframe format. Use the print() without calling the Ipython display then it should work. I re altered my solution above try it again!
the print (df) as opposed to simply 'df' seems to make all the diffference; thank you is there not a way to do this and keep the tabular style?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.