Zero-shot predictions in Pandas using the new BigQuery Accessor
Google Cloud integrates BigQuery AI functions directly into pandas DataFrames via a new BigQuery accessor, enabling zero-shot machine learning workflows without local model training.
Google Cloud has introduced a new .bigquery accessor for BigQuery DataFrames (BigFrames) that allows users to run advanced machine learning tasks—such as forecasting, classification, and embedding generation—directly within pandas DataFrames. This eliminates the need to extract data locally or train custom models, as AI functions like ai.predict() are executed remotely on BigQuery’s infrastructure. The accessor translates pandas operations into Google Standard SQL, leveraging foundational models like TabFM, and returns results as standard pandas DataFrames, maintaining a seamless workflow.
The accessor supports vector embedding generation with ai.embed(), which computes embeddings for entire text columns in a single expression. Behind the scenes, BigFrames handles the conversion to BigQuery, model execution, and output formatting, ensuring the process remains entirely within the pandas environment. Semantic similarity calculations are also streamlined using ai.similarity(), which compares Series elements against a target string or another Series, returning cosine similarity scores as a native pandas Series.
Time-series forecasting is simplified with ai.forecast(), which processes grouped structured data using high-level parameters like target metrics, timestamps, and prediction horizons. The function internally uses the TimesFM model, now available in Preview with model="TimesFM 3.0", which ranks first on GIFT-Eval, FEV-Bench, and TIME forecasting benchmarks. Results include forecast values, confidence levels, and prediction intervals, returned directly to the local environment as a pandas DataFrame.
Natural-language filtering is enabled via ai.if_(), which evaluates prompts built from literal strings and DataFrame columns, returning boolean Series for row filtering. By default, the function operates in optimized mode to minimize cost and latency, though users can switch to maximize_quality for higher accuracy. All AI functions integrate natively with pandas, allowing complex AI tasks to be performed without leaving the familiar Python ecosystem.