Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lever une exception si l'identifiant_unique n'est pas unique #1111

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions dags/create_final_actors.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ def apply_corrections_acteur(**kwargs):
lambda x: shortuuid.uuid(name=x)
)

# failed is identifiant unique is not unique in the dataframe df_acteur_merged
if not df_acteur_merged["identifiant_unique"].is_unique:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu fais 2 fois le travail:

Tu pourrais faire 1 fois avec:

  • df_duplicates = ... .duplicated(keep=False)
  • if not df_duplicates.empty:

# get duplicates
df_duplicates = df_acteur_merged[
df_acteur_merged["identifiant_unique"].duplicated(keep=False)
]
duplicates_identifiant_unique = (
df_duplicates["identifiant_unique"].unique().tolist()
)
raise ValueError(
"identifiant_unique is not unique in the dataframe df_acteur_merged :"
f" {duplicates_identifiant_unique}"
)

return {
"df_acteur_merged": df_acteur_merged,
# ["parent_id", "child_id", "child_source_id"]
Expand Down
Loading