Skip to content

Commit

Permalink
fix: add entity to contacts and deals
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentLvr committed Apr 17, 2024
1 parent c914e3a commit 1c8ed88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 12 additions & 9 deletions models/growth-engine/core/domain/Growth_Create_contacts_view.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@
" # Init\n",
" df = df_init.copy()\n",
" notes = {}\n",
" entities = {}\n",
" \n",
" # Cleaning\n",
" df = df[df[\"PROFILE_URL\"].isin(people)]\n",
Expand All @@ -366,16 +365,14 @@
" tmp_df = df.copy()\n",
" tmp_df = tmp_df[tmp_df[\"PROFILE_URL\"] == p].reset_index(drop=True)\n",
" interactions = []\n",
" owners = \", \".join(tmp_df[\"ENTITY\"].unique().tolist())\n",
" for row in tmp_df.itertuples():\n",
" # Append interaction text to create notes\n",
" interaction_text = row.INTERACTION_TEXT\n",
" interactions.append(interaction_text)\n",
" \n",
" # Add list to dict\n",
" notes[p] = interactions\n",
" entities[p] = owners\n",
" return notes, entities\n",
" return notes\n",
"\n",
"def create_contacts_view(\n",
" df_people,\n",
Expand All @@ -387,12 +384,18 @@
" entity_name,\n",
" limit_llm=50\n",
"):\n",
" # Entity\n",
" df_entity = df_interactions.copy()\n",
" df_entity = df_entity[[\"ENTITY\", \"PROFILE_URL\"]].drop_duplicates(\"PROFILE_URL\", keep=\"first\")\n",
" \n",
" # People\n",
" df1 = df_people.copy()\n",
" df1 = pd.merge(df_entity, df_people, how=\"inner\", on=\"PROFILE_URL\")\n",
" df1.loc[:, \"LEAD_STATUS\"] = \"Lead\"\n",
" df1.loc[df1[\"MQL_DATE\"] != \"NA\", \"LEAD_STATUS\"] = \"Marketing Qualified Lead\"\n",
" df1.loc[df1[\"SQL_DATE\"] != \"NA\", \"LEAD_STATUS\"] = \"Sales Qualified Lead\"\n",
" to_keep = [\n",
" 'ENTITY',\n",
" 'ID',\n",
" 'FULLNAME',\n",
" 'OCCUPATION',\n",
" 'SENIORITY',\n",
Expand All @@ -410,7 +413,7 @@
" ]\n",
" df1 = df1[to_keep]\n",
" for c in to_keep:\n",
" if \"DATE\" not in c and c not in [\"LEAD_STATUS\", \"ORGANIZATION\", \"CRM_CONTACT_ID\"]:\n",
" if \"DATE\" not in c and c not in ['ENTITY', \"LEAD_STATUS\", \"ORGANIZATION\", \"CRM_CONTACT_ID\"]:\n",
" df1 = df1.rename(columns={c: f\"PEOPLE_{c}\"})\n",
" \n",
" # Organizations\n",
Expand Down Expand Up @@ -439,7 +442,7 @@
" \n",
" # Merge dfs\n",
" df = pd.merge(df1, df2, how=\"left\").fillna('NA')\n",
" df = df.sort_values(by=\"SQL_DATE\", ascending=False)\n",
" df = df.sort_values(by=\"LAST_INTERACTION_DATE\", ascending=False)\n",
" \n",
" # Exclude entity org\n",
" df = df[df[\"ORGANIZATION\"] != organization].reset_index(drop=True)\n",
Expand All @@ -456,7 +459,7 @@
" print(\"-> New Sales Qualified Leads:\", len(filter_df))\n",
" # Create notes from interactions\n",
" profiles = filter_df[\"PEOPLE_PROFILE_URL\"].unique()\n",
" notes, entities = get_metadata_by_profile(df_interactions, profiles)\n",
" notes = get_metadata_by_profile(df_interactions, profiles)\n",
" filter_df[\"PEOPLE_NOTES\"] = filter_df[\"PEOPLE_PROFILE_URL\"].map(notes)\n",
"\n",
" # Generate messaging options for SQL\n",
Expand Down Expand Up @@ -519,7 +522,7 @@
" messaging_options,\n",
" entity_name\n",
")\n",
"df_contacts"
"df_contacts.head(1)"
]
},
{
Expand Down
2 changes: 2 additions & 0 deletions models/sales-engine/core/domain/Sales_Create_deals_db.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
" \n",
" # Filters on SQL\n",
" df = df[\n",
" (df[\"ENTITY\"].str.contains(entity_name)) & \n",
" (df[\"LEAD_STATUS\"].isin([\"Sales Qualified Lead\"]))\n",
" ]\n",
" print(\"Sales Qualified Lead:\", len(df))\n",
Expand Down Expand Up @@ -311,6 +312,7 @@
" \n",
" # Cleaning\n",
" to_order = [\n",
" \"ENTITY\",\n",
" \"SCENARIO\",\n",
" \"DEAL_NAME\",\n",
" \"SQL_DATE\",\n",
Expand Down

0 comments on commit 1c8ed88

Please sign in to comment.