Skip to content

Commit

Permalink
fixing and improving the nps computation
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickPassa committed Nov 7, 2023
1 parent f6b7a95 commit 816bb19
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions dags/nps_gip.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,37 @@ def store_gsheets(**kwargs):
for name, pub_sheet_url in Variable.get("NPS_NAME_PUB_SHEET_URL_TUPLES", deserialize_json=True):
print(f"reading {name=} at {pub_sheet_url=}")
sheet_df = pd.read_csv(pub_sheet_url)
sheet_df.rename(
columns={
"Submitted at": "Date",
"Dates": "Date",
sheet_df.columns[-1]: "Recommandation",
},
inplace=True,
)
column_name = "Quelle est la probabilité que vous recommandiez"
column_name += " La communauté de l'inclusion à un collègue, partenaire ou homologue ?"

# Identify the last column that contains an integer
last_integer_column = None
for column in sheet_df.columns:
if sheet_df[column].dtype == "int64":
last_integer_column = column

if last_integer_column is not None:
# Rename the last integer column
sheet_df.rename(
columns={
"Submitted at": "Date",
"Dates": "Date",
last_integer_column: "Recommandation",
},
inplace=True,
)
else:
if column_name in sheet_df.columns:
sheet_df.rename(
columns={
"Submitted at": "Date",
"Dates": "Date",
column_name: "Recommandation",
},
inplace=True,
)
else:
raise Exception("Our colleagues messed up the columns :(")
sheet_df["Produit"] = name
sheet_df = sheet_df[["Date", "Recommandation", "Produit"]]
df = pd.concat([df, sheet_df])
Expand Down

0 comments on commit 816bb19

Please sign in to comment.