File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change 45
45
46
46
47
47
class TableWidget (WIDGET_BASE ):
48
- """
49
- An interactive, paginated table widget for BigFrames DataFrames.
48
+ """An interactive, paginated table widget for BigFrames DataFrames.
49
+
50
+ This widget provides a user-friendly way to display and navigate through
51
+ large BigQuery DataFrames within a Jupyter environment.
50
52
"""
51
53
52
54
def __init__ (self , dataframe : bigframes .dataframe .DataFrame ):
@@ -75,15 +77,18 @@ def __init__(self, dataframe: bigframes.dataframe.DataFrame):
75
77
# Initialize data fetching attributes.
76
78
self ._batches = dataframe .to_pandas_batches (page_size = initial_page_size )
77
79
80
+ # Access total_rows through type casting (internal use only)
81
+ from bigframes .core .blocks import PandasBatches
82
+
83
+ if isinstance (self ._batches , PandasBatches ):
84
+ self .row_count = self ._batches .total_rows or 0
85
+ else :
86
+ # Fallback for compatibility
87
+ self .row_count = 0
88
+
78
89
# set traitlets properties that trigger observers
79
90
self .page_size = initial_page_size
80
91
81
- # len(dataframe) is expensive, since it will trigger a
82
- # SELECT COUNT(*) query. It is a must have however.
83
- # TODO(b/428238610): Start iterating over the result of `to_pandas_batches()`
84
- # before we get here so that the count might already be cached.
85
- self .row_count = len (dataframe )
86
-
87
92
# get the initial page
88
93
self ._set_table_html ()
89
94
You can’t perform that action at this time.
0 commit comments