Skip to content
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

Spp 6805 h value to boolean #86

Merged
merged 8 commits into from
Jun 28, 2022
8 changes: 5 additions & 3 deletions statistical_methods_library/estimation.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
import typing

from pyspark.sql import DataFrame
from pyspark.sql.functions import col, count, first, lit, sum
from pyspark.sql.functions import col, count, first, lit, sum, when


class ValidationError(Exception):
@@ -186,7 +186,9 @@ def estimate(
if death_marker_col is not None and h_value_col is not None:
col_list += [
col(death_marker_col).alias("death_marker"),
col(h_value_col).alias("h_value"),
when(col(h_value_col) == 1, True)
.when(col(h_value_col) == 0, False)
.alias("h_value"),
]

else:
@@ -214,7 +216,7 @@ def estimate(
.agg(
sum(col("sample_marker")),
sum(col("death_marker")),
first(col("h_value")),
first(col("h_value").cast("integer")).alias("first(h_value)"),
count(col("sample_marker")),
)
.withColumn(