Skip to content

Commit a604e56

Browse files
authored
docs: add how-to guide and include API reference (#33)
* docs: add how-to guide and include API reference * fix indentation * fix types in sample * fix types in sample
1 parent fc653d2 commit a604e56

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

bigquery/python-db-dtypes-pandas/snippets/pandas_date_and_time.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,54 +14,53 @@
1414

1515

1616
def pandas_date_and_time():
17-
# [START bigquery_date_create]
17+
# [START bigquery_pandas_date_create]
1818

1919
import datetime
2020
import pandas as pd
2121
import db_dtypes # noqa import to register dtypes
2222

2323
dates = pd.Series([datetime.date(2021, 9, 17), "2021-9-18"], dtype="dbdate")
2424

25-
# [END bigquery_date_create]
26-
# [START bigquery_date_as_datetime]
25+
# [END bigquery_pandas_date_create]
26+
# [START bigquery_pandas_date_as_datetime]
2727

2828
datetimes = dates.astype("datetime64")
2929

30-
# [END bigquery_date_as_datetime]
31-
# [START bigquery_date_sub]
30+
# [END bigquery_pandas_date_as_datetime]
31+
# [START bigquery_pandas_date_sub]
3232

3333
dates2 = pd.Series(["2021-1-1", "2021-1-2"], dtype="dbdate")
3434
diffs = dates - dates2
3535

36-
# [END bigquery_date_sub]
37-
# [START bigquery_date_do]
36+
# [END bigquery_pandas_date_sub]
37+
# [START bigquery_pandas_date_add_offset]
3838

3939
do = pd.DateOffset(days=1)
4040
after = dates + do
4141
before = dates - do
4242

43-
# [END bigquery_date_do]
44-
# [START bigquery_time_create]
43+
# [END bigquery_pandas_date_add_offset]
44+
# [START bigquery_pandas_time_create]
4545

4646
times = pd.Series([datetime.time(1, 2, 3, 456789), "12:00:00.6"], dtype="dbtime")
4747

48-
# [END bigquery_time_create]
49-
# [START bigquery_time_as_timedelta]
48+
# [END bigquery_pandas_time_create]
49+
# [START bigquery_pandas_time_as_timedelta]
5050

5151
timedeltas = times.astype("timedelta64")
5252

53-
# [END bigquery_time_as_timedelta]
54-
# [START bigquery_combine_date_time]
53+
# [END bigquery_pandas_time_as_timedelta]
5554

56-
combined = datetimes + timedeltas
55+
# Combine datetime64 and timedelta64 to confirm adding dates and times are
56+
# equivalent.
57+
combined0 = datetimes + timedeltas
5758

58-
# [END bigquery_combine_date_time]
59-
combined0 = combined
60-
# [START bigquery_combine2_date_time]
59+
# [START bigquery_pandas_combine_date_time]
6160

6261
combined = dates + times
6362

64-
# [END bigquery_combine2_date_time]
63+
# [END bigquery_pandas_combine_date_time]
6564

6665
return (
6766
dates,

0 commit comments

Comments
 (0)