too_many_questions
too_many_questions

Reputation: 553

ipython notebook view wide pandas dataframe vertically

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)

Upvotes: 4

Views: 8261

Answers (2)

Deepak M
Deepak M

Reputation: 1224

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)

Upvotes: 5

plhn
plhn

Reputation: 5263

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

df.head(3).transpose()

Upvotes: 13

Related Questions