Skip to content

Undesired UX behavior of DataFrame output in IPython Notebook #10231

Closed
@danieljl

Description

@danieljl

From my previous line comment at be80898#commitcomment-11338872. cc @takluyver @jorisvandenbossche

Because DataFrame's _repr_html_ returns hardcoded div tag with style max-height:1000px, if the height of DataFrame's output exceeds 1000px, it will generate a scroll bar.

First, it is unnecessary because IPython Notebook has "toggle output scrolling" feature. Second, it causes UX problem if the height of browser resolution is below 1000px (user must scroll twice: the whole page and the generated div). Third, it can't make use of "toggle output scrolling" feature (if user turn it on, it will generate nested scroll bars (worse UX)). For more detailed explanations and examples, see the steps to reproduce below.

Pandas version: 0.16.1.

Steps to reproduce:

  1. Open an IPython Notebook and paste this code. It will generate an inner scroll bar because the output's height exceeds 1000px.

    import pandas as pd
    pd.DataFrame(list(range(100)))
  2. If you want to see all rows, first you should scroll the page.
    a

  3. After you reach the bottom of the generated ouput's div, you should scroll again the inner scroll bar.
    b

  4. If you want to toggle the IPython Notebook's "toggle output scrolling" feature, you get this.
    c

Desired behaviors:

  • When "output scrolling" feature is off
    d
  • When "output scrolling" feature is on
    e

Solution:
Remove style property from div tag that DataFrame's _repr_html_ returns.
Old: <div style="max-height:1000px;max-width:1500px;overflow:auto;">\n
New: <div>\n

Why should max-width be removed as well? Because it also generates far worse UX. If you have so many columns that the horizontal scroll bar generated, you cannot scroll it. You must refresh the page to be able to scroll it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Output-Formatting__repr__ of pandas objects, to_string

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions