|
4 | 4 | "cell_type": "markdown", |
5 | 5 | "metadata": {}, |
6 | 6 | "source": [ |
7 | | - "# Pandas Extension for BigQuery DataFrames\n", |
| 7 | + "# BigQuery extension for pandas\n", |
8 | 8 | "\n", |
9 | 9 | "BigQuery DataFrames provides a pandas extension to execute BigQuery SQL scalar functions directly on pandas DataFrames." |
10 | 10 | ] |
11 | 11 | }, |
12 | 12 | { |
13 | 13 | "cell_type": "code", |
14 | | - "execution_count": null, |
| 14 | + "execution_count": 4, |
15 | 15 | "metadata": {}, |
16 | 16 | "outputs": [], |
17 | 17 | "source": [ |
18 | 18 | "import pandas as pd\n", |
19 | | - "import bigframes.pandas as bpd\n", |
20 | | - "import bigframes" |
| 19 | + "import bigframes # This import registers the bigquery accessor." |
21 | 20 | ] |
22 | 21 | }, |
23 | 22 | { |
|
31 | 30 | }, |
32 | 31 | { |
33 | 32 | "cell_type": "code", |
34 | | - "execution_count": null, |
| 33 | + "execution_count": 5, |
35 | 34 | "metadata": {}, |
36 | | - "outputs": [], |
| 35 | + "outputs": [ |
| 36 | + { |
| 37 | + "data": { |
| 38 | + "text/html": [ |
| 39 | + "\n", |
| 40 | + " Query processed 0 Bytes in a moment of slot time.\n", |
| 41 | + " " |
| 42 | + ], |
| 43 | + "text/plain": [ |
| 44 | + "<IPython.core.display.HTML object>" |
| 45 | + ] |
| 46 | + }, |
| 47 | + "metadata": {}, |
| 48 | + "output_type": "display_data" |
| 49 | + }, |
| 50 | + { |
| 51 | + "data": { |
| 52 | + "text/plain": [ |
| 53 | + "0 2.0\n", |
| 54 | + "1 3.0\n", |
| 55 | + "2 4.0\n", |
| 56 | + "dtype: Float64" |
| 57 | + ] |
| 58 | + }, |
| 59 | + "execution_count": 5, |
| 60 | + "metadata": {}, |
| 61 | + "output_type": "execute_result" |
| 62 | + } |
| 63 | + ], |
37 | 64 | "source": [ |
38 | 65 | "df = pd.DataFrame({\"a\": [1.5, 2.5, 3.5]})\n", |
39 | 66 | "result = df.bigquery.sql_scalar(\"ROUND({0}, 0)\")\n", |
|
49 | 76 | }, |
50 | 77 | { |
51 | 78 | "cell_type": "code", |
52 | | - "execution_count": null, |
| 79 | + "execution_count": 6, |
53 | 80 | "metadata": {}, |
54 | | - "outputs": [], |
| 81 | + "outputs": [ |
| 82 | + { |
| 83 | + "data": { |
| 84 | + "text/html": [ |
| 85 | + "\n", |
| 86 | + " Query processed 0 Bytes in a moment of slot time.\n", |
| 87 | + " " |
| 88 | + ], |
| 89 | + "text/plain": [ |
| 90 | + "<IPython.core.display.HTML object>" |
| 91 | + ] |
| 92 | + }, |
| 93 | + "metadata": {}, |
| 94 | + "output_type": "display_data" |
| 95 | + }, |
| 96 | + { |
| 97 | + "data": { |
| 98 | + "text/plain": [ |
| 99 | + "0 11\n", |
| 100 | + "1 22\n", |
| 101 | + "2 33\n", |
| 102 | + "dtype: Int64" |
| 103 | + ] |
| 104 | + }, |
| 105 | + "execution_count": 6, |
| 106 | + "metadata": {}, |
| 107 | + "output_type": "execute_result" |
| 108 | + } |
| 109 | + ], |
55 | 110 | "source": [ |
56 | 111 | "df = pd.DataFrame({\"a\": [1, 2, 3], \"b\": [10, 20, 30]})\n", |
57 | 112 | "result = df.bigquery.sql_scalar(\"{0} + {1}\")\n", |
|
61 | 116 | ], |
62 | 117 | "metadata": { |
63 | 118 | "kernelspec": { |
64 | | - "display_name": "Python 3", |
| 119 | + "display_name": "venv", |
65 | 120 | "language": "python", |
66 | 121 | "name": "python3" |
67 | 122 | }, |
|
0 commit comments