Skip to content

Commit

Permalink
Update NonValueTransformer's Default Setting and Handle Custom Fill V…
Browse files Browse the repository at this point in the history
…alues (#199)

* Update nan.py

* Update nan.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
MooooCat and pre-commit-ci[bot] committed Jul 11, 2024
1 parent 7c338ad commit 3998cd8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions sdgx/data_processors/transformers/nan.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ class NonValueTransformer(Transformer):
If `drop_na` is set to `False`, this value will be used to fill missing values in the data.
"""

drop_na = True
drop_na = False
"""
A boolean flag indicating whether to drop rows with missing values or fill them with `fill_na_value`.
If `True`, rows with missing values will be dropped. If `False`, missing values will be filled with `fill_na_value`.
If `True`, rows with missing values will be dropped.
If `False`, missing values will be filled with `fill_na_value`.
Currently, the default setting is False, which means rows with missing values are not dropped.
"""

def fit(self, metadata: Metadata | None = None, **kwargs: dict[str, Any]):
Expand All @@ -48,9 +51,13 @@ def fit(self, metadata: Metadata | None = None, **kwargs: dict[str, Any]):
"""
logger.info("NonValueTransformer Fitted.")

self.fitted = True
for key, value in kwargs.items():
if key == "fill_na_value":
if not isinstance(value, str):
raise ValueError("fill_na_value must be of type <str>")
self.fill_na_value = value

return
self.fitted = True

def convert(self, raw_data: DataFrame) -> DataFrame:
"""
Expand Down

0 comments on commit 3998cd8

Please sign in to comment.