1

I have written about 100 lines of code in a Jupyter Notebook cell, & in the middle of the code, I have something like this:

pd.set_option('display.max_rows', 1000)
x=np.random.rand(1000,3)
display(pd.DataFrame(x))

It shows me the entire table, but I was wondering if there is an option in Pandas to limit the vertical size of the output table & add a vertical scroll bar to allow better viewing. I mean, a separate vertical scroll bar than the cell output scroll bar (which I have toggled off by the way).

From what I understand, one option is to use Plotly table visualization as explained in this, but I wanted to avoid that if possible & use a more native solution because with plotly / Dash, the table text is not selectable anymore (Not sure haven't tested it yet though).

I just found the solution from Pandas DataFrame Table Vertical Scrollbars, I have to add this:

from IPython.display import display, HTML


# Puts the scrollbar next to the DataFrame
display(HTML("<div style='height: 200px; overflow: auto; width: fit-content'>" +
             df1.to_html() +
             "</div>"))
dani
  • 97
  • 9
  • 2
    Does this thread help: https://stackoverflow.com/questions/42724327/pandas-dataframe-table-vertical-scrollbars (particularly the updated part of the selected answer). – fhorrobin Feb 11 '22 at 19:04
  • @fhorrobin yes that was very helpful! I added the answer to the question text. – dani Feb 11 '22 at 19:13

0 Answers0