14
14
15
15
16
16
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
+
17
30
# [START bigquery_dataframes_bigquery_methods_struct]
18
31
import bigframes .bigquery as bbq
19
32
import bigframes .pandas as bpd
@@ -36,6 +49,22 @@ def test_bigquery_dataframes_examples() -> None:
36
49
# dtype: struct[pyarrow]
37
50
# [END bigquery_dataframes_bigquery_methods_struct]
38
51
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
+
39
68
# [START bigquery_dataframes_bigquery_methods_scalar]
40
69
import bigframes .bigquery as bbq
41
70
import bigframes .pandas as bpd
0 commit comments