Skip to content

Commit

Permalink
Merge branch 'main' into staging/flow-movidesk
Browse files Browse the repository at this point in the history
  • Loading branch information
akaBotelho committed Dec 27, 2024
2 parents 062421c + 3081fd0 commit 649f760
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
12 changes: 2 additions & 10 deletions pipelines/migration/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1557,16 +1557,8 @@ def transform_raw_to_nested_structure(

content_columns = [c for c in data.columns if c not in primary_key]
data["content"] = data.apply(
lambda row: json.dumps(
{
key: (
row[key]
if isinstance(row[key], (list, dict)) or not pd.isna(row[key])
else None
)
for key in content_columns
},
ensure_ascii=(
lambda row: row[[c for c in content_columns]].to_json(
force_ascii=(
constants.CONTROLE_FINANCEIRO_DATASET_ID.value not in raw_filepath
),
),
Expand Down
12 changes: 1 addition & 11 deletions pipelines/utils/pretreatment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
"""Functions to pretreat data"""
import json

import pandas as pd
from prefeitura_rio.pipelines_utils.logging import log
Expand All @@ -20,16 +19,7 @@ def transform_to_nested_structure(data: pd.DataFrame, primary_keys: list) -> pd.
"""
content_columns = [c for c in data.columns if c not in primary_keys]
data["content"] = data.apply(
lambda row: json.dumps(
{
key: (
row[key]
if isinstance(row[key], (list, dict)) or not pd.isna(row[key])
else None
)
for key in content_columns
}
),
lambda row: row[[c for c in content_columns]].to_json(),
axis=1,
)
return data[primary_keys + ["content"]]
Expand Down

0 comments on commit 649f760

Please sign in to comment.