@@ -956,6 +956,9 @@ def _create_html_representation(
956956 """Create an HTML representation of the DataFrame."""
957957 opts = bigframes .options .display
958958 with display_options .pandas_repr (opts ):
959+ # TODO(shuowei, b/464053870): Escaping HTML would be useful, but
960+ # `escape=False` is needed to show images. We may need to implement
961+ # a full-fledged repr module to better support types not in pandas.
959962 if bigframes .options .display .blob_display and blob_cols :
960963
961964 def obj_ref_rt_to_html (obj_ref_rt ) -> str :
@@ -981,6 +984,8 @@ def obj_ref_rt_to_html(obj_ref_rt) -> str:
981984 return f'uri: { obj_ref_rt_json ["objectref" ]["uri" ]} , authorizer: { obj_ref_rt_json ["objectref" ]["authorizer" ]} '
982985
983986 formatters = {blob_col : obj_ref_rt_to_html for blob_col in blob_cols }
987+
988+ # set max_colwidth so not to truncate the image url
984989 with pandas .option_context ("display.max_colwidth" , None ):
985990 html_string = pandas_df .to_html (
986991 escape = False ,
@@ -991,6 +996,7 @@ def obj_ref_rt_to_html(obj_ref_rt) -> str:
991996 formatters = formatters , # type: ignore
992997 )
993998 else :
999+ # _repr_html_ stub is missing so mypy thinks it's a Series. Ignore mypy.
9941000 html_string = pandas_df ._repr_html_ () # type:ignore
9951001
9961002 html_string += f"[{ row_count } rows x { column_count } columns in total]"
0 commit comments