Closed karticn-google closed 1 year ago
@statmike I have created this issue to update the cell from markdown to code and fix couple typos in the query.
Good Catch!
It looks like I was editing it as markdown and copy/pasted an extra sum(n) OVER() ..
in the middle of the word total
.
Corrections made and pushed this morning.
Switch cell type from Markdown to code for this cell:
query = f""" WITH COUNTS as (SELECT splits, {VAR_TARGET}, count(*) as n FROM {BQ_PROJECT}.{BQ_DATASET}.{BQ_TABLE} GROUP BY splits, {VAR_TARGET})
SELECT *, SAFE_DIVIDE(n, SUM(n) OVER(PARTITION BY {VAR_TARGET})) as n_pct_class, SAFE_DIVIDE(n, SUM(n) OVER(PARTITION BY splits)) as n_pct_split, SAFE_DIVIDE(SUM(n) OVER(PARTITION BY {VAR_TARGET}), SUM(n) OVER()) as class_pct_to SUM(n) OVER() as total,tal FROM COUNTS """ review = bq.query(query = query).to_dataframe() review
Add comma after to
SUM(n) OVER()) as class_pct_to
Remove the last attribute in the query
tal