Skip to content

Commit

Permalink
fix: categorical type and better json unpack policy
Browse files Browse the repository at this point in the history
  • Loading branch information
MatsMoll committed Feb 17, 2022
1 parent 9abdbcc commit b3b5937
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bender/transformation/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def unpack(self, column: Series, key: str) -> Series:
class UnpackString(UnpackPolicy):
def unpack(self, column: Series, key: str) -> Series:
bracket = '}'
regex_str = rf'"{key}"[\s:]+"([\w ]+)["{bracket},]'
regex_str = rf'"{key}"[\s:]+"([\w\d\s\\.-]+)["{bracket},]'
return column.astype(str).str.extract(regex_str).astype(str)


Expand Down Expand Up @@ -503,7 +503,7 @@ async def transform(self, df: DataFrame) -> DataFrame:
return df


class ToCatagorical(Transformation):
class ToCategorical(Transformation):

input: str
output: str
Expand Down
6 changes: 3 additions & 3 deletions bender/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Relation,
SetIndex,
SplitString,
ToCatagorical,
ToCategorical,
UnpackJson,
UnpackPolicy,
)
Expand Down Expand Up @@ -56,8 +56,8 @@ def fill_missing(feature: str, policy: FillPolicy) -> FillMissingValue:
return FillMissingValue(feature, policy)

@staticmethod
def to_catigorical(feature: str, output: Optional[str] = None) -> ToCatagorical:
return ToCatagorical(feature, feature if output is None else output)
def to_categorical(feature: str, output: Optional[str] = None) -> ToCategorical:
return ToCategorical(feature, feature if output is None else output)

@staticmethod
def log_to_console(data: Callable[[DataFrame], Any]) -> LogToConsole:
Expand Down

0 comments on commit b3b5937

Please sign in to comment.