|
35 | 35 | "execution_count": 2, |
36 | 36 | "id": "ca22f059", |
37 | 37 | "metadata": {}, |
38 | | - "outputs": [ |
39 | | - { |
40 | | - "name": "stderr", |
41 | | - "output_type": "stream", |
42 | | - "text": [ |
43 | | - "/usr/local/google/home/shuowei/src/python-bigquery-dataframes/venv/lib/python3.10/site-packages/google/api_core/_python_version_support.py:266: FutureWarning: You are using a Python version (3.10.15) which Google will stop supporting in new releases of google.api_core once it reaches its end of life (2026-10-04). Please upgrade to the latest Python version, or at least Python 3.11, to continue receiving updates for google.api_core past that date.\n", |
44 | | - " warnings.warn(message, FutureWarning)\n" |
45 | | - ] |
46 | | - } |
47 | | - ], |
| 38 | + "outputs": [], |
48 | 39 | "source": [ |
49 | 40 | "import bigframes.pandas as bpd" |
50 | 41 | ] |
|
151 | 142 | { |
152 | 143 | "data": { |
153 | 144 | "application/vnd.jupyter.widget-view+json": { |
154 | | - "model_id": "473b016aa6b24c86aafc6372352e822d", |
| 145 | + "model_id": "aafd4f912b5f42e0896aa5f0c2c62620", |
155 | 146 | "version_major": 2, |
156 | | - "version_minor": 1 |
| 147 | + "version_minor": 0 |
157 | 148 | }, |
158 | 149 | "text/plain": [ |
159 | 150 | "TableWidget(page_size=10, row_count=5552452, table_html='<table border=\"1\" class=\"dataframe table table-stripe…" |
|
214 | 205 | { |
215 | 206 | "data": { |
216 | 207 | "application/vnd.jupyter.widget-view+json": { |
217 | | - "model_id": "339279cc312e4e7fb67923e4e6ad7779", |
| 208 | + "model_id": "5ec0ad9f11874d4f9d8edbc903ee7b5d", |
218 | 209 | "version_major": 2, |
219 | | - "version_minor": 1 |
| 210 | + "version_minor": 0 |
220 | 211 | }, |
221 | 212 | "text/plain": [ |
222 | 213 | "TableWidget(page_size=10, row_count=5552452, table_html='<table border=\"1\" class=\"dataframe table table-stripe…" |
223 | 214 | ] |
224 | 215 | }, |
225 | | - "execution_count": 7, |
226 | 216 | "metadata": {}, |
227 | | - "output_type": "execute_result" |
| 217 | + "output_type": "display_data" |
228 | 218 | } |
229 | 219 | ], |
230 | 220 | "source": [ |
|
314 | 304 | { |
315 | 305 | "data": { |
316 | 306 | "application/vnd.jupyter.widget-view+json": { |
317 | | - "model_id": "8ff1f64c44304da0944eadbd0fb3981d", |
| 307 | + "model_id": "651b5aac958c408183775152c2573a03", |
318 | 308 | "version_major": 2, |
319 | | - "version_minor": 1 |
| 309 | + "version_minor": 0 |
320 | 310 | }, |
321 | 311 | "text/plain": [ |
322 | 312 | "TableWidget(page_size=10, row_count=5, table_html='<table border=\"1\" class=\"dataframe table table-striped tabl…" |
323 | 313 | ] |
324 | 314 | }, |
325 | | - "execution_count": 9, |
326 | 315 | "metadata": {}, |
327 | | - "output_type": "execute_result" |
| 316 | + "output_type": "display_data" |
328 | 317 | } |
329 | 318 | ], |
330 | 319 | "source": [ |
|
334 | 323 | "print(f\"Small dataset pages: {math.ceil(small_widget.row_count / small_widget.page_size)}\")\n", |
335 | 324 | "small_widget" |
336 | 325 | ] |
337 | | - }, |
338 | | - { |
339 | | - "cell_type": "markdown", |
340 | | - "id": "added-cell-2", |
341 | | - "metadata": {}, |
342 | | - "source": [ |
343 | | - "### Displaying Generative AI results containing JSON\n", |
344 | | - "The `AI.GENERATE` function in BigQuery returns results in a JSON column. While BigQuery's JSON type is not natively supported by the underlying Arrow `to_pandas_batches()` method used in anywidget mode ([Apache Arrow issue #45262](https://github.com/apache/arrow/issues/45262)), BigQuery Dataframes automatically converts JSON columns to strings for display. This allows you to view the results of generative AI functions seamlessly." |
345 | | - ] |
346 | | - }, |
347 | | - { |
348 | | - "cell_type": "code", |
349 | | - "execution_count": 10, |
350 | | - "id": "added-cell-1", |
351 | | - "metadata": {}, |
352 | | - "outputs": [ |
353 | | - { |
354 | | - "data": { |
355 | | - "text/html": [ |
356 | | - "✅ Completed. \n", |
357 | | - " Query processed 85.9 kB in 15 seconds of slot time.\n", |
358 | | - " " |
359 | | - ], |
360 | | - "text/plain": [ |
361 | | - "<IPython.core.display.HTML object>" |
362 | | - ] |
363 | | - }, |
364 | | - "metadata": {}, |
365 | | - "output_type": "display_data" |
366 | | - }, |
367 | | - { |
368 | | - "name": "stderr", |
369 | | - "output_type": "stream", |
370 | | - "text": [ |
371 | | - "/usr/local/google/home/shuowei/src/python-bigquery-dataframes/bigframes/dtypes.py:969: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n", |
372 | | - "instead of using `db_dtypes` in the future when available in pandas\n", |
373 | | - "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n", |
374 | | - " warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n" |
375 | | - ] |
376 | | - }, |
377 | | - { |
378 | | - "data": { |
379 | | - "text/html": [ |
380 | | - "✅ Completed. " |
381 | | - ], |
382 | | - "text/plain": [ |
383 | | - "<IPython.core.display.HTML object>" |
384 | | - ] |
385 | | - }, |
386 | | - "metadata": {}, |
387 | | - "output_type": "display_data" |
388 | | - }, |
389 | | - { |
390 | | - "data": { |
391 | | - "application/vnd.jupyter.widget-view+json": { |
392 | | - "model_id": "a6d61e48cca642b7a57e6431359b4cc4", |
393 | | - "version_major": 2, |
394 | | - "version_minor": 1 |
395 | | - }, |
396 | | - "text/plain": [ |
397 | | - "TableWidget(page_size=10, row_count=5, table_html='<table border=\"1\" class=\"dataframe table table-striped tabl…" |
398 | | - ] |
399 | | - }, |
400 | | - "metadata": {}, |
401 | | - "output_type": "display_data" |
402 | | - }, |
403 | | - { |
404 | | - "data": { |
405 | | - "text/html": [], |
406 | | - "text/plain": [ |
407 | | - "Computation deferred. Computation will process 0 Bytes" |
408 | | - ] |
409 | | - }, |
410 | | - "execution_count": 10, |
411 | | - "metadata": {}, |
412 | | - "output_type": "execute_result" |
413 | | - } |
414 | | - ], |
415 | | - "source": [ |
416 | | - "bpd._read_gbq_colab(\"\"\"\n", |
417 | | - " SELECT\n", |
418 | | - " AI.GENERATE(\n", |
419 | | - " prompt=>(\\\"Extract the values.\\\", OBJ.GET_ACCESS_URL(OBJ.FETCH_METADATA(OBJ.MAKE_REF(gcs_path, \\\"us.conn\\\")), \\\"r\\\")),\n", |
420 | | - " connection_id=>\\\"bigframes-dev.us.bigframes-default-connection\\\",\n", |
421 | | - " output_schema=>\\\"publication_date string, class_international string, application_number string, filing_date string\\\") AS result,\n", |
422 | | - " *\n", |
423 | | - " FROM `bigquery-public-data.labeled_patents.extracted_data`\n", |
424 | | - " LIMIT 5;\n", |
425 | | - "\"\"\")" |
426 | | - ] |
427 | 326 | } |
428 | 327 | ], |
429 | 328 | "metadata": { |
|
0 commit comments