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

Commit b5a7652

Browse files
authored
chore: include pandas accessors in api logging (#2524)
Follow-up to #2518 🦕
1 parent 6b0509b commit b5a7652

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

bigframes/extensions/pandas/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,15 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
"""
16+
BigQuery DataFrames automatically registers a pandas extenstion when imported.
17+
This allows you to use the power of the BigQuery engine with pandas objects
18+
directly.
19+
"""
20+
21+
from bigframes.extensions.pandas.dataframe_accessor import (
22+
PandasBigQueryDataFrameAccessor,
23+
)
24+
25+
__all__ = ["PandasBigQueryDataFrameAccessor"]

bigframes/extensions/pandas/dataframe_accessor.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
import pandas.api.extensions
1919

2020
import bigframes.core.global_session as bf_session
21+
from bigframes.core.logging import log_adapter
2122
import bigframes.pandas as bpd
2223

2324

24-
class AIAccessor:
25+
@log_adapter.class_logger
26+
class PandasAIAccessor:
2527
"""
2628
Pandas DataFrame accessor for BigQuery AI functions.
2729
"""
@@ -101,7 +103,8 @@ def forecast(
101103

102104

103105
@pandas.api.extensions.register_dataframe_accessor("bigquery")
104-
class BigQueryDataFrameAccessor:
106+
@log_adapter.class_logger
107+
class PandasBigQueryDataFrameAccessor:
105108
"""
106109
Pandas DataFrame accessor for BigQuery DataFrames functionality.
107110
@@ -112,11 +115,11 @@ def __init__(self, pandas_obj: pandas.DataFrame):
112115
self._obj = pandas_obj
113116

114117
@property
115-
def ai(self) -> "AIAccessor":
118+
def ai(self) -> "PandasAIAccessor":
116119
"""
117120
Accessor for BigQuery AI functions.
118121
"""
119-
return AIAccessor(self._obj)
122+
return PandasAIAccessor(self._obj)
120123

121124
def sql_scalar(self, sql_template: str, *, output_dtype=None, session=None):
122125
"""

docs/reference/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ BigQuery DataFrames provides extensions to pandas DataFrame objects.
2727
.. autosummary::
2828
:toctree: api
2929

30-
bigframes.extensions.pandas.dataframe_accessor.BigQueryDataFrameAccessor
30+
bigframes.extensions.pandas
3131

3232
ML APIs
3333
~~~~~~~

tests/unit/extensions/pandas/test_registration.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ def test_bigframes_import_registers_accessor():
2222
df = pd.DataFrame({"a": [1]})
2323
# If bigframes was imported, df.bigquery should exist
2424
assert hasattr(df, "bigquery")
25-
from bigframes.extensions.pandas.dataframe_accessor import BigQueryDataFrameAccessor
25+
from bigframes.extensions.pandas.dataframe_accessor import (
26+
PandasBigQueryDataFrameAccessor,
27+
)
2628

27-
assert isinstance(df.bigquery, BigQueryDataFrameAccessor)
29+
assert isinstance(df.bigquery, PandasBigQueryDataFrameAccessor)

0 commit comments

Comments
 (0)