Skip to content

Commit df24c84

Browse files
chore: add code samples for Data Manipulation public doc (#1722)
* chore: add code samples for Data Manipulation public doc * fix sample format * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 8ef4de1 commit df24c84

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

samples/snippets/bigquery_modules_test.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@
1414

1515

1616
def test_bigquery_dataframes_examples() -> None:
17+
# [START bigquery_dataframes_bigquery_methods_array_agg]
18+
import bigframes.bigquery as bbq
19+
import bigframes.pandas as bpd
20+
21+
s = bpd.Series([0, 1, 2, 3, 4, 5])
22+
23+
# Group values by whether they are divisble by 2 and aggregate them into arrays
24+
bbq.array_agg(s.groupby(s % 2 == 0))
25+
# False [1 3 5]
26+
# True [0 2 4]
27+
# dtype: list<item: int64>[pyarrow]
28+
# [END bigquery_dataframes_bigquery_methods_array_agg]
29+
1730
# [START bigquery_dataframes_bigquery_methods_struct]
1831
import bigframes.bigquery as bbq
1932
import bigframes.pandas as bpd
@@ -36,6 +49,22 @@ def test_bigquery_dataframes_examples() -> None:
3649
# dtype: struct[pyarrow]
3750
# [END bigquery_dataframes_bigquery_methods_struct]
3851

52+
# [START bigquery_dataframes_bigquery_methods_unix_micros]
53+
import pandas as pd
54+
55+
import bigframes.bigquery as bbq
56+
import bigframes.pandas as bpd
57+
58+
# Create a series that consists of three timestamps: [1970-01-01, 1970-01-02, 1970-01-03]
59+
s = bpd.Series(pd.date_range("1970-01-01", periods=3, freq="d", tz="UTC"))
60+
61+
bbq.unix_micros(s)
62+
# 0 0
63+
# 1 86400000000
64+
# 2 172800000000
65+
# dtype: Int64
66+
# [END bigquery_dataframes_bigquery_methods_unix_micros]
67+
3968
# [START bigquery_dataframes_bigquery_methods_scalar]
4069
import bigframes.bigquery as bbq
4170
import bigframes.pandas as bpd

0 commit comments

Comments
 (0)