@@ -130,31 +130,6 @@ def __init__(self, data, axes=None, copy=False, dtype=None,
130
130
object .__setattr__ (self , '_data' , data )
131
131
object .__setattr__ (self , '_item_cache' , {})
132
132
133
- def _ipython_display_ (self ):
134
- try :
135
- from IPython .display import display
136
- except ImportError :
137
- return None
138
-
139
- # Series doesn't define _repr_html_ or _repr_latex_
140
- latex = self ._repr_latex_ () if hasattr (self , '_repr_latex_' ) else None
141
- html = self ._repr_html_ () if hasattr (self , '_repr_html_' ) else None
142
- try :
143
- table_schema = self ._repr_table_schema_ ()
144
- except Exception as e :
145
- warnings .warn ("Cannot create table schema representation. "
146
- "{}" .format (e ), UnserializableWarning )
147
- table_schema = None
148
- # We need the inital newline since we aren't going through the
149
- # usual __repr__. See
150
- # https://github.com/pandas-dev/pandas/pull/14904#issuecomment-277829277
151
- text = "\n " + repr (self )
152
-
153
- reprs = {"text/plain" : text , "text/html" : html , "text/latex" : latex ,
154
- "application/vnd.dataresource+json" : table_schema }
155
- reprs = {k : v for k , v in reprs .items () if v }
156
- display (reprs , raw = True )
157
-
158
133
def _repr_table_schema_ (self ):
159
134
"""
160
135
Not a real Jupyter special repr method, but we use the same
@@ -6283,6 +6258,38 @@ def logical_func(self, axis=None, bool_only=None, skipna=None, level=None,
6283
6258
return set_function_name (logical_func , name , cls )
6284
6259
6285
6260
6261
+ def _ipython_display_ (self ):
6262
+ # Having _ipython_display_ defined messes with the return value
6263
+ # from cells, so the Out[x] dictionary breaks.
6264
+ # Currently table schema is the only thing using it, so we'll
6265
+ # monkey patch `_ipython_display_` onto NDFrame when config option
6266
+ # is set
6267
+ # see https://github.com/pandas-dev/pandas/issues/16168
6268
+ try :
6269
+ from IPython .display import display
6270
+ except ImportError :
6271
+ return None
6272
+
6273
+ # Series doesn't define _repr_html_ or _repr_latex_
6274
+ latex = self ._repr_latex_ () if hasattr (self , '_repr_latex_' ) else None
6275
+ html = self ._repr_html_ () if hasattr (self , '_repr_html_' ) else None
6276
+ try :
6277
+ table_schema = self ._repr_table_schema_ ()
6278
+ except Exception as e :
6279
+ warnings .warn ("Cannot create table schema representation. "
6280
+ "{}" .format (e ), UnserializableWarning )
6281
+ table_schema = None
6282
+ # We need the inital newline since we aren't going through the
6283
+ # usual __repr__. See
6284
+ # https://github.com/pandas-dev/pandas/pull/14904#issuecomment-277829277
6285
+ text = "\n " + repr (self )
6286
+
6287
+ reprs = {"text/plain" : text , "text/html" : html , "text/latex" : latex ,
6288
+ "application/vnd.dataresource+json" : table_schema }
6289
+ reprs = {k : v for k , v in reprs .items () if v }
6290
+ display (reprs , raw = True )
6291
+
6292
+
6286
6293
# install the indexes
6287
6294
for _name , _indexer in indexing .get_indexers_list ():
6288
6295
NDFrame ._create_indexer (_name , _indexer )
0 commit comments