Skip to content

Instantly share code, notes, and snippets.

@joshreini1
Created June 15, 2023 14:18
Show Gist options
  • Save joshreini1/fcbe2db8911f67bc9973aba90af3e169 to your computer and use it in GitHub Desktop.
Save joshreini1/fcbe2db8911f67bc9973aba90af3e169 to your computer and use it in GitHub Desktop.
query_attributions = """#standardsql
SELECT
(SELECT attribution FROM UNNEST(top_feature_attributions) WHERE feature = 'pageviews') AS pageviews,
(SELECT attribution FROM UNNEST(top_feature_attributions) WHERE feature = 'country') AS country,
(SELECT attribution FROM UNNEST(top_feature_attributions) WHERE feature = 'is_mobile') AS device_id,
(SELECT attribution FROM UNNEST(top_feature_attributions) WHERE feature = 'os') AS os
FROM 'gcp-sandbox-311420.bqml_tutorial.sample model preds explanations 0701 0708'
"""
job_attr = client.query(query_attributions)
df_attr = job_attr.to_dataframe()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment