Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# See the OpenDP Library docs for more on making private means:
# https://docs.opendp.org/en/OPENDP_V_VERSION/getting-started/tabular-data/essential-statistics.html#Mean

EXPR_NAME = pl.col(COLUMN_NAME).cast(float).dp.mean((LOWER_BOUND, UPPER_BOUND))
EXPR_NAME = pl.col(COLUMN_NAME).dp.mean((LOWER_BOUND, UPPER_BOUND))
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# https://docs.opendp.org/en/OPENDP_V_VERSION/getting-started/tabular-data/essential-statistics.html#Median

EXPR_NAME = (
pl.col(COLUMN_NAME)
.cast(float)
.dp.quantile(0.5, make_cut_points(LOWER_BOUND, UPPER_BOUND, bin_count=BIN_COUNT))
pl.col(COLUMN_NAME).dp.quantile(
0.5, make_cut_points(LOWER_BOUND, UPPER_BOUND, bin_count=BIN_COUNT)
)
# Or use "dp.median" which provides 0.5 implicitly.
)
8 changes: 4 additions & 4 deletions tests/utils/test_code_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_make_column_config_block_for_mean():
== f"""# See the OpenDP Library docs for more on making private means:
# https://docs.opendp.org/en/v{opendp_version}/getting-started/tabular-data/essential-statistics.html#Mean

hw_grade_expr = pl.col('HW GRADE').cast(float).dp.mean((0, 100))"""
hw_grade_expr = pl.col('HW GRADE').dp.mean((0, 100))"""
)


Expand All @@ -70,9 +70,9 @@ def test_make_column_config_block_for_median():
# https://docs.opendp.org/en/v{opendp_version}/getting-started/tabular-data/essential-statistics.html#Median

hw_grade_expr = (
pl.col('HW GRADE')
.cast(float)
.dp.quantile(0.5, make_cut_points(0, 100, bin_count=20))
pl.col('HW GRADE').dp.quantile(
0.5, make_cut_points(0, 100, bin_count=20)
)
# Or use "dp.median" which provides 0.5 implicitly.
)""" # noqa: B950 (too long!)
)
Expand Down
Loading