-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fix undesired UX behavior of DataFrame output in IPython Notebook #10232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Could you please squash this to a single commit and add this to the release notes for 0.16.2? I think this would go in under "Other API changes": https://github.com/pydata/pandas/blob/master/doc/source/whatsnew/v0.16.2.txt @jorisvandenbossche @jreback any thoughts on this issue? see also the associated issue #10231 |
8941b83
to
1aa2c04
Compare
@shoyer I've squashed it into a single commit. Btw, I think this is more appropriate added to release notes under "Other enhancements", isn't it? |
@@ -25,6 +25,8 @@ New features | |||
Other enhancements | |||
^^^^^^^^^^^^^^^^^^ | |||
|
|||
- Fix undesired UX behavior of DataFrame output in IPython Notebook. (:issue:`10231`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might say: "Removed duplicate scroll bars in DataFrame HTML representation in IPython Notebook" (just to be a little more descriptive)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeh, this needs a bit more explanation. Possibly even a screen shot. Its seems trivial, but people complain about UX changes the most!
@danieljl This is a (small) API change, so I would put it under that category. "Other enhancements" is really for fully backwards compatible changes, e.g., adding a new optional keyword argument. |
Personally I don't think it is needed to put it under API changes, as it is not really something that will break people's code, or something for which people have to adjust there code, it is only a visual change. I would keep 'API changes' for things people have to pay attention to if they use that in their code. |
I was only thinking: how does this behave in older versions of IPython? (eg somebody who is still using IPython 2?) |
@jorisvandenbossche would you call this a bug fix? It's kind of a strange case -- we had a work around, which was resolved in a later version of IPython. See the linked issue for screenshots. |
Maybe we can detect the IPython version and dependable on that leave the max-width in or not? @shoyer hmm, maybe also not a bug fix. I would keep it at an 'enhancement' of the visual output of a dataframe in the notebook. But does not really matter that much I think |
I agree with @jorisvandenbossche I would detect ipython version and not make any change for ipython < 3. Further, I think this needs a separate section in the what's new with a picture. UX changes needs to be announced loudly (even if its is a 'bug' fix). |
@danieljl can you update with ipython version detection? |
@jreback Done. However, in IPython 2 horizontal scroll bar is still unscrollable unless the page is refreshed. |
@@ -22,6 +22,7 @@ | |||
from numpy import nan as NA | |||
import numpy as np | |||
import numpy.ma as ma | |||
import IPython |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a required dependency, so do this in the actual function. surround with a try/except
. if you cannot figure out the version (e.g. ipython is not installed), then use the new style is ok.
try: | ||
import IPython | ||
|
||
if IPython.version_info < (3, 0, 0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IPython.version_info < LooseVersion("3.0.0")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jreback IPython.version_info
is a tuple. Did you mean IPython.__version__
? Btw, why is this more preferred?
Put this code as a method in This needs to be changed a bit. Instead of simply having the Then just call this code in This will put all of the code in the correct place, and make it obvious what is going on. |
7e73bec
to
3e0c851
Compare
@jreback Should it be like this 3e0c851? |
@@ -25,6 +25,8 @@ New features | |||
Other enhancements | |||
^^^^^^^^^^^^^^^^^^ | |||
|
|||
- Removed duplicate scroll bars in DataFrame HTML representation in IPython Notebook. (:issue:`10231`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for notebook >= version 3.0.0
pls squash this to a single commit |
@@ -25,6 +25,8 @@ New features | |||
Other enhancements | |||
^^^^^^^^^^^^^^^^^^ | |||
|
|||
- Removed duplicate scroll bars in DataFrame HTML representation for IPython 3.0.0 or later. (:issue:`10231`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs some addtl explanation w.r.t. max_rows
. IOW, I find that using pd.set_setoption('max_rows,None)
is now a nice way to use the notebook (for a terminal I have this set to a smaller value, however). maybe mention of same in options.rst
@shoyer @jorisvandenbossche @TomAugspurger @sinhrks thoughts? |
looks good. |
lgtm. |
Yep, looks pretty good to me. |
Yes, here as well. I quickly tested it, and although I was used to having shorter outputs of dataframes in my notebook workflow (now it show about 30 rows, with this change the full 60 rows of a truncated dataframe repr will be visible, leading to a longer output), I think I will get used to the change. The only disadvantage is that I find the "toggle output scrolling" feature of IPython (with this, you see around 9 rows) rather ugly (the way too heavy shadow). |
@jreback Squashed |
@jorisvandenbossche agreed, it is a little ugly to have a drop shadow here. But this is still better than double scroll bars. |
@danieljl that looks good. can you expand the whatsnew note a bit? approach this from the perspective of someone reading this, and since this is a UX change, we want to be obvious/clear what exactly this is. |
@jreback Whatsnew updated :) |
One comment: this adds a new |
@jorisvandenbossche Yup, initially I implemented it in |
I guess we could make it |
OK, agreed. Other option is to call
or if you think this is useful in |
how about then we make this an argument to |
So should the code be refactored again? |
@@ -1387,7 +1387,8 @@ def to_html(self, buf=None, columns=None, col_space=None, colSpace=None, | |||
escape=escape, | |||
max_rows=max_rows, | |||
max_cols=max_cols, | |||
show_dimensions=show_dimensions) | |||
show_dimensions=show_dimensions, | |||
notebook=notebook) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here pass directly to .to_html()
(and add in the doc-string). That way this is not relevant to DataFrameFormatter
, just to the HTMLFormatter
(which is created in the .to_html
call)
If everything's okay, I will squash it again. |
lgtm. go ahead and squash |
Done |
merged via 814dbe8 thanks! |
Closes #10231