Display "long" pandas dataframe in jupyter notebook with "foldover"?
<p>Let's say I have a pandas dataframe with many columns:</p>

<p><a href="http://i.stack.imgur.com/bjFlz.png" rel="nofollow"><img src="http://i.stack.imgur.com/bjFlz.png" alt="enter image description here"></a></p>

<p>I can view all of the columns by scrolling left/right. However, this is a bit inconvenient and I was wondering if there was an elegant way to display the table with "foldover":</p>

<p><a href="http://i.stack.imgur.com/2Aten.png" rel="nofollow"><img src="http://i.stack.imgur.com/2Aten.png" alt="enter image description here"></a></p>

<p>To generate the above, I manually chopped up the dataframe into chunks and displayed each chunk (which is why the spacing/etc is not perfect).</p>

<p>I was wondering if there was a way to do something like the above more cleanly, possibly by changing pandas or jupyter settings?</p>

<p>In addition to setting max cols like you did, I'm importing <code>display</code></p>

<pre><code>import pandas as pd
pd.set_option('display.max_columns', None)

from IPython.display import display
</code></pre>

<p>creating a frame then a simple for loop to display every 30 cols</p>

<pre><code>df = pd.DataFrame([range(200)])

cols = df.shape[1]

for i in range(0,cols,30):   
    display(df.iloc[:,i:i+30])
</code></pre>

<p>EDIT: Forgot to add a pic of the output</p>

<p><a href="http://i.stack.imgur.com/UT7ya.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/UT7ya.jpg" alt="enter image description here"></a></p>

python pandas ipython jupyter jupyter-notebook