Skip to content
Snippets Groups Projects
Commit 685ce79d authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

ENH(transformers): added better logic for converting to bool

parent 197bf0ab
Branches
Tags
Loading
Pipeline #58314 passed
......@@ -127,11 +127,20 @@ def cast_to_bool(in_value: Any, params: dict) -> bool:
"""
Cast the `in_value` to bool.
This is done by comparing `in_value` to "True".
Only "true", "True", "False" and "false" are accepted as possible values.
All other input values raise an error.
Parameters
==========
No parameters.
"""
return bool(in_value)
val = str(in_value).lower()
if val == "true":
return True
if val == "false":
return False
raise ValueError("Invalid value for type cast to bool: {}".format(in_value))
def cast_to_str(in_value: Any, params: dict) -> str:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment