Skip to content

Commit

Permalink
fix: JSON number unpack policy
Browse files Browse the repository at this point in the history
  • Loading branch information
MatsMoll committed Feb 22, 2022
1 parent 04de645 commit aeaa4fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bender/transformation/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def __init__(self, metric: Callable[[SeriesGroupBy], Series]) -> None:

def unpack(self, column: Series, key: str) -> Series:
bracket = '}'
regex_str = rf'"{key}"[\s:]+(\d+)[{bracket},]'
regex_str = rf'"{key}"[\s:]+"?([\d.]+)"?[{bracket},]'
grouped = column.astype(str).str.extractall(regex_str).reset_index(level='match', drop=True).reset_index()
grouped.columns = ['index', 'value']
# Is needed to set type to float, as it can otherwise lead to bugs
Expand Down
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def json_df() -> DataFrame:
'json_data': [
# Different json formatting is intentional
# Therefore testing if the regex is correct
'[{"value": 1},{"value": 1},{"value":2, "other": 10},{"value": 4}]',
'[{"value": 1},{"value": 1},{"value":2, "other": 10},{"value": "4"}]',
'[{"value": 1},{"value": 1},{"value": 1},{"value": 1}]',
],
'value_median': [1.5, 1],
Expand Down

0 comments on commit aeaa4fb

Please sign in to comment.