-
Notifications
You must be signed in to change notification settings - Fork 50
docs: add the first sample for the Single time-series forecasting from Google Analytics data tutorial #623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
dcf3b26
create_single_timeseries_forecasting_model_test.py code sample
bac37c8
Merge branches 'main' and 'main' of github.com:googleapis/python-bigq…
adc22ef
fix: forecast method to forecast time series
SalemJorden 6376885
Merge branch 'main' of github.com:googleapis/python-bigquery-datafram…
SalemJorden 2b09dd4
Merge remote-tracking branch 'upstream/main' into salem_timeseriessample
SalemJorden d3ea7c7
pair programming PR draft creation
SalemJorden 17cbd68
tutorial step 7 & 8
SalemJorden 3588fee
merging branches
SalemJorden 2ecceae
concat function for visualizing forecasting results
SalemJorden 8a2a612
docs: single time series code sample step 2
SalemJorden 673c6e3
suggested changes to step 2
SalemJorden 647b1c2
docs: edit text because wildcare tables are supported
SalemJorden 310d33d
code review changes
SalemJorden 88667a9
remove unused variable
SalemJorden 279cc04
Merge branch 'main' into Salem_STS2
tswast 2a52bb2
Merge branch 'main' into Salem_STS2
tswast aedfa6a
Merge branch 'main' into Salem_STS2
tswast File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
samples/snippets/create_single_timeseries_forecasting_model_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (t | ||
# you may not use this file except in compliance wi | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in | ||
# distributed under the License is distributed on a | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, eit | ||
# See the License for the specific language governi | ||
# limitations under the License. | ||
|
||
|
||
def test_create_single_timeseries(): | ||
|
||
# [START bigquery_dataframes_single_timeseries_forecasting_model_tutorial] | ||
import bigframes.pandas as bpd | ||
|
||
# Start by loading the historical data from BigQuerythat you want to analyze and forecast. | ||
# This clause indicates that you are querying the ga_sessions_* tables in the google_analytics_sample dataset. | ||
# Read and visualize the time series you want to forecast. | ||
df = bpd.read_gbq("bigquery-public-data.google_analytics_sample.ga_sessions_*") | ||
parsed_date = bpd.to_datetime(df.date, format="%Y%m%d", utc=True) | ||
visits = df["totals"].struct.field("visits") | ||
total_visits = visits.groupby(parsed_date).sum() | ||
|
||
# Expected output: total_visits.head() | ||
# date | ||
# 2016-08-01 00:00:00+00:00 1711 | ||
# 2016-08-02 00:00:00+00:00 2140 | ||
# 2016-08-03 00:00:00+00:00 2890 | ||
# 2016-08-04 00:00:00+00:00 3161 | ||
# 2016-08-05 00:00:00+00:00 2702 | ||
# Name: visits, dtype: Int64 | ||
|
||
total_visits.plot.line() | ||
|
||
# [END bigquery_dataframes_single_timeseries_forecasting_model_tutorial] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.