Conversation
This adds a new `ai` property to `BigQueryDataFrameAccessor` which returns an `AIAccessor`. The `AIAccessor` provides a `forecast` method that calls `bigframes.bigquery.ai.forecast`, converting the Pandas DataFrame to a BigFrames DataFrame and the result back to a Pandas DataFrame. Co-authored-by: tswast <247555+tswast@users.noreply.github.com>
| The time points column provides the time points used to generate the forecast. | ||
| The time points column must use one of the following data types: TIMESTAMP, DATE and DATETIME | ||
| model (str, default "TimesFM 2.0"): | ||
| A str value that specifies the name of the model. TimesFM 2.0 is the only supported value, and is the default value. |
There was a problem hiding this comment.
@jules According to https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-forecast, "TimesFM 2.5" is also supported. We should link to https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-forecast in the docstring, above.
There was a problem hiding this comment.
Added a link to the standard-sql documentation for ai.forecast and updated the model param documentation to include TimesFM 2.5.
| The DataFrame is converted to BigFrames by calling ``read_pandas``, then the forecast | ||
| is generated using ``bigframes.bigquery.ai.forecast``, and the result is | ||
| converted back to a pandas DataFrame using ``to_pandas``. |
There was a problem hiding this comment.
@jules This is an implementation detail that doesn't belong in the docstring.
There was a problem hiding this comment.
Removed the implementation details regarding read_pandas and to_pandas from the docstring.
| model: str = "TimesFM 2.0", | ||
| id_cols: Optional[Iterable[str]] = None, | ||
| horizon: int = 10, | ||
| confidence_level: float = 0.95, |
There was a problem hiding this comment.
@jules Missing the output_historical_time_series boolean parameter.
There was a problem hiding this comment.
Added the missing output_historical_time_series boolean parameter and documented it.
| @@ -0,0 +1,25 @@ | |||
| import pandas as pd | |||
There was a problem hiding this comment.
@jules missing the license header.
There was a problem hiding this comment.
Added the missing Apache 2.0 license header to tests/system/small/extensions/test_dataframe_accessor.py.
* Updated documentation to refer to BigQuery AI.FORECAST syntax. * Removed internal implementation details (`read_pandas` and `to_pandas`) from docstring. * Added missing `output_historical_time_series` parameter. * Added missing copyright headers to `tests/system/small/extensions/test_dataframe_accessor.py`. Co-authored-by: tswast <247555+tswast@users.noreply.github.com>
df.bigquery.ai.forecast method to pandas dataframe accessor
There was a problem hiding this comment.
I'm curious if this triggers our logger.
My gut feeling says yes, because our logger only seems to track the call stack of annotated classes / functions. However, I still feel like to double check with you on this.
There was a problem hiding this comment.
It should trigger the logger, but I think we should probably add labels that are specific to the dataframe accessor. I'll follow-up with that.
PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release. Librarian Version: v0.7.0 Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:160860d189ff1c2f7515638478823712fa5b243e27ccc33a2728669fa1e2ed0c <details><summary>bigframes: 2.39.0</summary> ## [2.39.0](v2.38.0...v2.39.0) (2026-03-31) ### Features * add `df.bigquery.ai.forecast` method to pandas dataframe accessor (#2518) ([1126cec](1126cec9)) * support full round-trip persistence for multimodal reference cols (#2511) ([494a0a1](494a0a11)) * expose DataFrame.bigquery in both pandas and bigframes DataFrames (#2533) ([69fe317](69fe3176)) ### Bug Fixes * to_gbq may swap data columns when replace table (#2532) ([17ecc65](17ecc65e)) * handle aggregate operations on empty selections (#2510) ([34fb5da](34fb5daa)) * Localize BigQuery log suppression for gbq.py (#2541) ([af49ca2](af49ca29)) * Respect remote function config changes even if logic unchanged (#2512) ([b952428](b9524284)) * support melting empty DataFrames without crashing (#2509) ([e8c4603](e8c46032)) ### Performance Improvements * Make executor data uploads async internally (#2529) ([96597f0](96597f0b)) ### Documentation * gemini retouch of the index page for seo (#2514) ([2e5311e](2e5311e2)) * Rename Blob column references to ObjectRef column (#2535) ([44e0ffd](44e0ffd9)) </details>

Adds the
.bigquery.ai.forecast()method to pandas DataFrame objects, which proxies tobigframes.bigquery.ai.forecast(). Added unit tests and mocked session responses.PR created automatically by Jules for task 14604090974587392182 started by @tswast