Skip to content
This repository was archived by the owner on May 7, 2026. It is now read-only.

Commit 38899b7

Browse files
committed
refactor: consolidate object metadata extraction for display
1 parent c0f4b4e commit 38899b7

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

bigframes/display/html.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,19 @@ def obj_ref_rt_to_html(obj_ref_rt) -> str:
179179
return html_string
180180

181181

182+
def _get_obj_metadata(
183+
obj: Union[bigframes.dataframe.DataFrame, bigframes.series.Series],
184+
) -> tuple[bool, bool]:
185+
from bigframes.series import Series
186+
187+
is_series = isinstance(obj, Series)
188+
if is_series:
189+
has_index = len(obj._block.index_columns) > 0
190+
else:
191+
has_index = obj._has_index
192+
return is_series, has_index
193+
194+
182195
def get_anywidget_bundle(
183196
obj: Union[bigframes.dataframe.DataFrame, bigframes.series.Series],
184197
include=None,
@@ -219,11 +232,7 @@ def get_anywidget_bundle(
219232
total_columns,
220233
blob_cols if "blob_cols" in locals() else [],
221234
)
222-
is_series = isinstance(obj, Series)
223-
if is_series:
224-
has_index = len(obj._block.index_columns) > 0
225-
else:
226-
has_index = obj._has_index
235+
is_series, has_index = _get_obj_metadata(obj)
227236
widget_repr["text/plain"] = plaintext.create_text_representation(
228237
cached_pd,
229238
total_rows,
@@ -269,11 +278,7 @@ def repr_mimebundle_head(
269278
obj, pandas_df, row_count, column_count, blob_cols
270279
)
271280

272-
is_series = isinstance(obj, Series)
273-
if is_series:
274-
has_index = len(obj._block.index_columns) > 0
275-
else:
276-
has_index = obj._has_index
281+
is_series, has_index = _get_obj_metadata(obj)
277282
text_representation = plaintext.create_text_representation(
278283
pandas_df,
279284
row_count,

0 commit comments

Comments
 (0)