{"data":{"slug":"github-google-skills-skills-cloud-bigquery-bigframes-00da2214c3e3","title":"BigQuery DataFrame (BigFrames) for Data Analysis","summary":"Use BigFrames to perform data analysis and machine learning tasks on BigQuery using Python. Generate Python code for data processing, analysis, and machine learning directly in BigQuery without downloading data.","url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-bigquery-bigframes-00da2214c3e3","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-google-skills-skills-cloud-bigquery-bigframes-00da2214c3e3","markdown_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-bigquery-bigframes-00da2214c3e3.md","download_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-bigquery-bigframes-00da2214c3e3\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"Before executing any `gcloud`, REST API, or MCP command, you must read [Usage Attribution](references\/attribution.md). For commands executed directly in the terminal, prefix `gcloud` with `CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\/1.0 (skill:bigquery-bigframes)\"` and append `agent-skills\/1.0 (skill:bigquery-bigframes)` to `User-Agent` headers.","instructions":"---\nname: bigquery-bigframes\nmetadata:\n  version: \"2.0.1\"\n  category: BigDataAndAnalytics\ndescription: >-\n  Generates Python code using BigQuery DataFrames (BigFrames). Use by default for any Python data task involving BigQuery, including data processing, analysis, and machine learning. Don't use for SQL-first workflows or the google-cloud-bigquery client library \u2014 use bigquery-basics.\n\n---\n\n# BigFrames (BigQuery DataFrame) basics\nBigFrames is a Python library that lets you take advantage of BigQuery\ndata processing by using familiar Python APIs.\n\n## Attribution\n\n**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you\nMUST read [Usage Attribution](references\/attribution.md). For commands executed\ndirectly in the terminal (never in generated scripts, Terraform, or user code),\nprefix `gcloud` with\n`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\/1.0 (skill:bigquery-bigframes)\"`\nand append `agent-skills\/1.0 (skill:bigquery-bigframes)` to `User-Agent` headers.\n\n## Dataframe API best practices\n\n* **Stay in the Cloud**: Perform data cleaning, transformation, and analysis\n  via BigFrames methods to leverage BigQuery's scale rather than downloading\n  data.\n* **Prefer partial ordering mode**: Enable partial ordering mode right after\n    importing BigFrames. This speeds up data processing significantly by relaxing\n    row-sequence constraints.\n\n    ```python\n    import bigframes.pandas as bpd\n    bpd.options.bigquery.ordering_mode = 'partial'\n    ```\n* **Use `peek()` for data preview**: Use `peek(n)` to preview data instead of\n  `head(n)`. `peek(n)` randomly samples `n` rows and is significantly faster.\n  `head(n)` returns rows in strict order and fails in `partial` ordering mode\n  unless the DataFrame has been explicitly sorted.\n* **Avoid materializing data locally**: Methods like `to_pandas()` download all\n  data to client memory, bypassing BigQuery\u2019s distributed computation and\n  risking Out of Memory (OOM) errors. Do not materialize data locally unless:\n  * The dataset is small enough to fit safely in memory.\n  * An error message explicitly requires local materialization.\n* **Prefer Dataframe API over SQL queries**: Do not write raw SQL queries via\n  `read_gbq()` if a DataFrame\/Series method achieves the same result, as it\n  breaks the Pandas abstraction and prevents lazy query execution.\n* **Accessors over UDFs\/Lambdas**:\n    * Use built-in accessors (e.g., `df.col.str.*`, `df.col.dt.*`) instead of\n      remote User Defined Functions (UDFs). UDFs require extra resources and\n      time to deploy.\n    * Do not use lambdas with `Series.map()` or `DataFrame.apply()`. These\n      methods do not accept functions without `udf` or `remote_function`\n      decorators.\n    ```python\n    # Avoid:\n    df[\"upper\"] = df[\"name\"].map(lambda x: x.upper())\n\n    # Prefer:\n    df[\"upper\"] = df[\"name\"].str.upper()\n    ```\n* **Schema Verification**: Do not assume the schema of intermediate outputs.\n  Proactively verify schemas using `.dtypes` and inspect sample records using\n  `display()` with `.peek()`.\n* **Visualization**: Plot directly from the BigFrames DataFrame\/Series when\n  possible. BigFrames is compatible with Matplotlib and Seaborn. If direct\n  plotting fails, use the `.plot` accessor. If the dataset is too large to plot,\n  aggregate or sample the data before calling\n  `.to_pandas()` to plot locally.\n\n## Machine Learning\n* **Use `bigframes.bigquery.ml` package**: Do not use Scikit-learn or other ML\n  libraries with BigQuery DataFrames. Standard Scikit-learn models require\n  bringing data into local client memory, whereas `bigframes.bigquery.ml`\n  delegates training directly to BigQuery's scalable ML engine. Import functions\n  from `bigframes.bigquery.ml`.\n\n### Reference Directory\n* [Linear Regression](references\/linear_regression.md): Train a linear\n  regression model to predict numerical values.\n* [Logistic Regression](references\/logistic_regression.md): Train a logistic\n  regression model to predict boolean values.\n\n## BigFrames ML (Legacy)\n\nThe BigFrames ML package (`bigframes.ml`) is a legacy package that mimics the\nscikit-learn API but is no longer recommended for new projects. Only use this\npackage if the user explicitly requests BigFrames ML.\n\n* **Legacy Imports**: When legacy BigFrames ML is requested, import tools and\n  classes from `bigframes.ml` instead of `bigframes.bigquery.ml`.\n* **DataFrame Return on Prediction**: Unlike Scikit-learn, BigFrames'\n  `predict()` method always returns a **DataFrame** containing both predictions\n  and features, rather than a single series of predictions.\n* **No `random_state`**: Do not pass a `random_state` argument when\n  instantiating BigFrames ML models, as this parameter is not supported in the\n  BigFrames ML package.\n* **Automatic Scaling**: Do not use `OneHotEncoder` or `StandardScaler` unless\n  explicitly requested, as scaling is handled automatically.\n* **Hyperparameter Tuning**: Write custom loops for hyperparameter tuning, as\n  BigFrames lacks `GridSearchCV` or `RandomizedSearchCV`.\n* **ARIMA Plus** (Forecasting):\n    * Import from `bigframes.ml.forecasting`.\n    * Sort data chronologically and split around a timepoint before training.\n    * Ensure the prediction horizon is less than or equal to the training\n      horizon.\n* **PCA**: BigFrames' PCA class lacks a `transform()` method. Use `predict()`\n  instead.\n* **Model Persistence**: To persist a model, use `model.to_gbq()`. To load a\n  persisted model, use `bpd.read_gbq_model()`.\n","use_cases":["Perform data cleaning, transformation, and analysis directly on BigQuery without downloading data.","Train machine learning models using BigFrames' ML package for scalable predictions.","Preview data using `peek()` for faster results without sorting constraints."],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/google\/skills\/blob\/e3c591afe426ea585e4c21799e5199d6d47cd1be\/skills\/cloud\/bigquery-bigframes\/SKILL.md","source_commit":"e3c591afe426ea585e4c21799e5199d6d47cd1be","license":null,"version":null,"listing_approved_at":"2026-11-17","created_at":"2026-11-16T11:44:55.000000Z","updated_at":"2026-11-17T05:10:16.000000Z","seo_title":"BigQuery DataFrame for Data Analysis","seo_description":"Use BigFrames to perform data analysis and machine learning tasks on BigQuery using Python. Efficient and scalable data processing.","seo_keywords":["BigQuery DataFrame analysis","BigFrames data processing","BigQuery machine learning","BigFrames ML training","BigQuery data preview"]}}