@@ -92,6 +92,16 @@ def __init__(self, dataframe: bigframes.dataframe.DataFrame):
9292
9393 self ._dataframe = dataframe
9494
95+ self ._cell_execution_count = None
96+ try :
97+ import IPython
98+
99+ ipy = IPython .get_ipython ()
100+ if ipy is not None and hasattr (ipy , "execution_count" ):
101+ self ._cell_execution_count = ipy .execution_count
102+ except (ImportError , NameError ):
103+ pass
104+
95105 super ().__init__ ()
96106
97107 # Initialize attributes that might be needed by observers first
@@ -286,7 +296,10 @@ def _reset_batch_cache(self) -> None:
286296 def _reset_batches_for_new_page_size (self ) -> None :
287297 """Reset the batch iterator when page size changes."""
288298 with bigframes .option_context ("display.progress_bar" , None ):
289- self ._batches = self ._dataframe .to_pandas_batches (page_size = self .page_size )
299+ self ._batches = self ._dataframe .to_pandas_batches (
300+ page_size = self .page_size ,
301+ cell_execution_count = self ._cell_execution_count ,
302+ )
290303
291304 self ._reset_batch_cache ()
292305
@@ -318,7 +331,8 @@ def _set_table_html(self) -> None:
318331 current_sort_state = _SortState (tuple (sort_columns ), tuple (sort_ascending ))
319332 if self ._last_sort_state != current_sort_state :
320333 self ._batches = df_to_display .to_pandas_batches (
321- page_size = self .page_size
334+ page_size = self .page_size ,
335+ cell_execution_count = self ._cell_execution_count ,
322336 )
323337 self ._reset_batch_cache ()
324338 self ._last_sort_state = current_sort_state
0 commit comments