Skip to content

_repr_html_ returns None #9323

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
lbillingham opened this issue Jan 21, 2015 · 7 comments
Closed

_repr_html_ returns None #9323

lbillingham opened this issue Jan 21, 2015 · 7 comments

Comments

@lbillingham
Copy link

In previous versions, the Spyder IDE displayed HTML for DataFrames in its iPython console. In 0.15.2 they are no longer displayed.

I think this may be to do with DataFrame._repr_html_()

If I run the following on 0.15.2:

import pandas as pd
import numpy as np

print('pandas version ', pd.__version__)
rng = pd.date_range(start='2014-01-01', periods=5, freq='D')
df = pd.DataFrame({'y':np.random.normal(size=len(rng))}, index=rng)
ret = df._repr_html_()
print(None == ret)

it prints 0.15.2, True

and viewing the DataFrame with df results in the text rendering:
image

On 0.14.1, running the above I get 0.14.1, False
and df results in this:
image

@shoyer
Copy link
Member

shoyer commented Jan 21, 2015

Can you share pd.show_versions()?

@lbillingham
Copy link
Author

Oh, is this maybe an IPython thing? There are different versions of that on the 2 boxen.

repr_html() == None

INSTALLED VERSIONS

commit: None
python: 2.7.7.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en_GB

pandas: 0.15.2
nose: 1.3.4
Cython: 0.20.1
numpy: 1.9.1
scipy: 0.15.0
statsmodels: 0.5.0
IPython: 2.3.1
sphinx: 1.2.3
patsy: 0.2.1
dateutil: 1.5
pytz: 2014.9
bottleneck: None
tables: 3.1.1
numexpr: 2.3.1
matplotlib: 1.3.1
openpyxl: 1.8.5
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: 0.5.5
lxml: 3.3.5
bs4: 4.3.1
html5lib: None
httplib2: None
apiclient: None
rpy2: None
sqlalchemy: 0.9.4
pymysql: None
psycopg2: None

repr_html() != None

INSTALLED VERSIONS

commit: None
python: 2.7.8.final.0
python-bits: 32
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.14.1
nose: 1.3.4
Cython: 0.21
numpy: 1.9.0
scipy: 0.14.0
statsmodels: 0.5.0
IPython: 2.2.0
sphinx: 1.2.3
patsy: 0.3.0
scikits.timeseries: None
dateutil: 1.5
pytz: 2014.7
bottleneck: None
tables: 3.1.1
numexpr: 2.3.1
matplotlib: 1.4.0
openpyxl: 1.8.5
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: 0.5.7
lxml: 3.4.0
bs4: 4.3.2
html5lib: None
httplib2: None
apiclient: None
rpy2: None
sqlalchemy: 0.9.7
pymysql: None
psycopg2: None

@shoyer
Copy link
Member

shoyer commented Jan 21, 2015

Can you verify that you're using running the same version of Spyder in both environments?

I have two other things you can try that might give us a hint: what do you get from running pd.core.common.in_qtconsole() and pd.get_option("display.notebook_repr_html") ?

@jorisvandenbossche
Copy link
Member

xref #7372

I also saw that Spyder now shows the text repr and no longer the html repr (and I think this is a good idea, see the issue I linked -> can lead to strange effects. And the ipython devs are even removing the default html displaying from the qtconsole in ipython 3.0, as I understand).
But for me, I thought this was due to upgrading my spyder from 2.3.0 to 2.3.2, so indeed, can you check your spyder versions?

@lbillingham
Copy link
Author

They are running different versions of Spyder and in_qtconsole() has changed

###repr_html() == None
Spyder version 2.3.2

pd.get_option("display.notebook_repr_html")
True

pd.core.common.in_qtconsole()
True

###repr_html() != None
Spyder version 2.3.0

pd.get_option("display.notebook_repr_html")
True


pd.core.common.in_qtconsole()
False

I'd say this was closed.

I couldn't find anything in the release notes for Spyder about this. I've suggest adding something.
https://code.google.com/p/spyderlib/issues/detail?id=2126

Thank you for your help.

@jorisvandenbossche
Copy link
Member

So to summarize: pandas has a in_qtconsole function that is used to not show the html repr in qtconsole as this is not done properly (see comment here: https://github.com/pydata/pandas/blob/v0.15.2/pandas/core/frame.py#L505).
Spyder changed some things in 2.3.2 to let the ipython console behave like a 'real' qtconsole for pandas in order to fix a bug (https://code.google.com/p/spyderlib/issues/detail?id=2015), but also with the result that now the text repr is used.

@ccordoba12 Maybe you can add this to your changelog?

@ccordoba12
Copy link

@jorisvandenbossche @lbillingham I didn't think this was important enough to merit a changelog note :-) I'll add one for our next release because I doubt people read old changelogs.

In a way this was not our fault. The problem was in_qtconsole was not doing their job correctly (by assuming that the only way to have a qtconsole is to run ipython qtconsole and detecting the application name). I just noticed it when a user reported our issue 2015

I hope you fix this behavior :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants