Skip to content

Commit 17d8fb1

Browse files
committed
updates DataFrame._repr_html_ to return None in Anywidget display mode. This forces IPython environments to use _repr_mimebundle_ for rendering, enabling rich interactive Anywidget displays for DataFrames in notebooks.
1 parent 7b8abc9 commit 17d8fb1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

bigframes/dataframe.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
import pyarrow
5656
import tabulate
5757

58-
import bigframes
5958
import bigframes._config.display_options as display_options
6059
import bigframes.constants
6160
import bigframes.core
@@ -947,6 +946,17 @@ def _repr_mimebundle_(self, include=None, exclude=None):
947946

948947
return {"text/html": html_string, "text/plain": text_representation}
949948

949+
def _repr_html_(self):
950+
"""
951+
Renders the DataFrame as HTML.
952+
This method is used by IPython to display the DataFrame.
953+
"""
954+
# If in anywidget mode, return None to defer to _repr_mimebundle_
955+
# which will provide the richer anywidget representation.
956+
if bigframes.options.display.repr_mode == "anywidget":
957+
return None
958+
return self._repr_mimebundle_()["text/html"]
959+
950960
def _create_html_representation(
951961
self,
952962
pandas_df: pandas.DataFrame,

0 commit comments

Comments
 (0)