Skip to content

Strange behaviour of DataFrame html repr in qtconsole #7372

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

Closed
jorisvandenbossche opened this issue Jun 6, 2014 · 7 comments
Closed

Strange behaviour of DataFrame html repr in qtconsole #7372

jorisvandenbossche opened this issue Jun 6, 2014 · 7 comments
Labels
Output-Formatting __repr__ of pandas objects, to_string

Comments

@jorisvandenbossche
Copy link
Member

Don't know if this is related to the new changes in 0.14 in the display of Dataframes or to #7180. But I find the following behaviour with 0.14 in Spyders IPython qtconsole:

new picture 7

To reproduce:

df = pd.DataFrame(np.random.randn(2,20), columns=list('ABCDEFGHIJKLMNOPQRST'))
df['very_long_column_name'] = [1,2]
df['X'] = ['very_long_column_values', 'other_long_string']
  • This seems not a very usefull behaviour to me?
    Should it truncate on width rather than number of columns?
  • It is also not truncating (above dataframe has 22 columns, while default max_columns is 20 (and I checked the setting)), while it truncated correctly for the text repr.

Other strange thing, I saw this in the Spyder IPython console (which is an embedded qtconsole I think). However, when I tried this in a qtconsole, it gave me first the text repr instead of the html repr (although pd.options.display.notebook_html_repr was set to True), so I used HTML(df.to_html()) for the above picture (but the result is the same as in Spyder).

@bjonen

@jorisvandenbossche
Copy link
Member Author

I checked it with 0.13.1 and 0.12.0, and there the issue is the same. So probably not related to the latest changes to the display.

@jreback
Copy link
Contributor

jreback commented Jun 6, 2014

related maybe to #7059

@bjonen
Copy link
Contributor

bjonen commented Jun 9, 2014

In the notebook it looks fine http://nbviewer.ipython.org/gist/bjonen/06646fbe7f716a20f8fd

What's the import for HTML?

@jorisvandenbossche
Copy link
Member Author

from IPython.display import HTML

The difference with the qtconsole is that there you don't have horizontal scrolling. So there should be more aggresive truncating based on the console width or something I think.

Now, what you see with HTML(df.to_html()) is a way to replicate it, because I think it is logical that it is not truncated here (as you explicitely converted it to HTML before printing it). So the fact about not truncating I said above, you can neglect that.
But apart from that, I get this behaviour in the Spyder's console with the default display.

@takluyver
Copy link
Contributor

We (IPython) have changed the Qt console to not attempt to display HTML, because it does such a bad job on anything non-trivial. With IPython 3 installed, you should get the text representation instead of the HTML insider Spyder (since Spyder is just embedding the IPython Qt console).

IPython 3 is due for release late summer or early autumn, but the change should already be evident if you run a dev version of IPython.

@jorisvandenbossche
Copy link
Member Author

When updating my spyder from 2.3.0 to 2.3.2, I noticed this issue is fixed (shows the text repr by default and no longer the HTML repr), so I think this can be closed.

Or is there something else we should fix at the pandas side?

@takluyver
Copy link
Contributor

No, I think it's fine to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

No branches or pull requests

4 participants