Skip to content

Commit

Permalink
altera transform_to_nested_structure
Browse files Browse the repository at this point in the history
  • Loading branch information
akaBotelho committed Dec 26, 2024
1 parent 217751d commit 2a6478f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pipelines/utils/pretreatment.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ def transform_to_nested_structure(data: pd.DataFrame, primary_keys: list) -> pd.
data["content"] = data.apply(
lambda row: json.dumps(
{
key: value if not pd.isna(value) else None
for key, value in row[content_columns].to_dict().items()
key: (
row[key]
if isinstance(row[key], (list, dict)) or not pd.isna(row[key])
else None
)
for key in content_columns
}
),
axis=1,
Expand Down

0 comments on commit 2a6478f

Please sign in to comment.