diff --git a/explorations/KPI_CONTRIBUTION.ipynb b/explorations/KPI_CONTRIBUTION.ipynb index ce16fd2..b280ce8 100644 --- a/explorations/KPI_CONTRIBUTION.ipynb +++ b/explorations/KPI_CONTRIBUTION.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "7a3c12c9", + "id": "2c69e2c4", "metadata": {}, "source": [ "# PAGE - CONTRIBUTION\n", @@ -20,7 +20,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "fff5c5f0", + "id": "a2601df1", "metadata": {}, "outputs": [], "source": [ @@ -42,7 +42,7 @@ }, { "cell_type": "markdown", - "id": "4c0d7dc7-95af-4ac2-bc7e-1cd633285f8c", + "id": "23e8eea5", "metadata": {}, "source": [ "### Interval\n", @@ -53,7 +53,7 @@ { "cell_type": "code", "execution_count": 2, - "id": "5b356180-62cf-4981-a259-a9d32664f8de", + "id": "990ba8fd", "metadata": {}, "outputs": [], "source": [ @@ -63,7 +63,7 @@ }, { "cell_type": "markdown", - "id": "dd07dd65", + "id": "dc4cbfc8", "metadata": {}, "source": [ "### Requête ES" @@ -72,7 +72,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "d53a28c2", + "id": "0c24fd43", "metadata": {}, "outputs": [ { @@ -121,7 +121,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "b39eb07a", + "id": "1e883965", "metadata": {}, "outputs": [ { @@ -145,7 +145,7 @@ }, { "cell_type": "markdown", - "id": "f078799e", + "id": "4c2c97a6", "metadata": {}, "source": [ "## Nombres de visites par contribution générique" @@ -153,7 +153,7 @@ }, { "cell_type": "markdown", - "id": "6bb27abb", + "id": "8f2492f6", "metadata": {}, "source": [ "### Préparation des données\n", @@ -164,7 +164,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "79604d1a", + "id": "3a79f864", "metadata": {}, "outputs": [], "source": [ @@ -178,7 +178,7 @@ }, { "cell_type": "markdown", - "id": "6f2bd408", + "id": "2583b872", "metadata": {}, "source": [ "### Ratio de complétion par contribution\n", @@ -190,7 +190,7 @@ { "cell_type": "code", "execution_count": 11, - "id": "7fd85d5f", + "id": "fe2eb71c", "metadata": {}, "outputs": [ { @@ -235,7 +235,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "e34f79ea-0de2-4495-ae89-fd7b19847592", + "id": "1a415ca3", "metadata": {}, "outputs": [ { @@ -854,7 +854,7 @@ }, { "cell_type": "markdown", - "id": "8f5a7c49-99c7-4225-96fa-426b7cdfcd40", + "id": "ec6d3ab6", "metadata": {}, "source": [ "### Sauvegarde du tableau dans un fichier CSV\n", @@ -865,7 +865,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "db8e5e9a-939c-4ce8-afda-7cfb039b973d", + "id": "92f588da", "metadata": {}, "outputs": [], "source": [ @@ -875,7 +875,7 @@ { "cell_type": "code", "execution_count": null, - "id": "51dd1e57-99ac-4f6e-9355-dd26fb3432f6", + "id": "17eaaf90", "metadata": {}, "outputs": [], "source": [] @@ -897,7 +897,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.10.12" } }, "nbformat": 4, diff --git a/explorations/KPI_OUTIL_TROUVER_SA_CC.ipynb b/explorations/KPI_OUTIL_TROUVER_SA_CC.ipynb index f5d100f..8a6581c 100644 --- a/explorations/KPI_OUTIL_TROUVER_SA_CC.ipynb +++ b/explorations/KPI_OUTIL_TROUVER_SA_CC.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "e96dbf98", + "id": "19563213", "metadata": {}, "source": [ "# OUTIL - TROUVER SA CONVENTION COLLECTIVE\n", @@ -20,7 +20,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ba23b516", + "id": "123d1284", "metadata": {}, "outputs": [], "source": [ @@ -42,7 +42,7 @@ }, { "cell_type": "markdown", - "id": "70b6793a", + "id": "127712e1", "metadata": {}, "source": [ "### Interval\n", @@ -53,17 +53,17 @@ { "cell_type": "code", "execution_count": null, - "id": "784abc3c", + "id": "d6941ff6", "metadata": {}, "outputs": [], "source": [ - "date_debut = '2024-10-01'\n", - "date_fin = '2024-11-01'" + "date_debut = '2024-11-01'\n", + "date_fin = '2024-12-01'" ] }, { "cell_type": "markdown", - "id": "3a4643de", + "id": "5ad4c9d0", "metadata": {}, "source": [ "### Convention collectives supportées\n", @@ -74,7 +74,7 @@ { "cell_type": "code", "execution_count": null, - "id": "de6993ba", + "id": "075f6c2d", "metadata": {}, "outputs": [], "source": [ @@ -83,7 +83,7 @@ }, { "cell_type": "markdown", - "id": "e800666e", + "id": "542efaf6", "metadata": {}, "source": [ "### Requête ES" @@ -92,7 +92,7 @@ { "cell_type": "code", "execution_count": null, - "id": "91f59895", + "id": "2ca44b46", "metadata": {}, "outputs": [], "source": [ @@ -135,7 +135,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4f6b8e7e", + "id": "e3b73f7c", "metadata": {}, "outputs": [], "source": [ @@ -145,7 +145,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17edf0ba", + "id": "a5185868", "metadata": {}, "outputs": [], "source": [ @@ -156,7 +156,7 @@ }, { "cell_type": "markdown", - "id": "729c49b4", + "id": "873d1e0d", "metadata": {}, "source": [ "## Taux des visites où l'utilisateur a obtenu sa convention collective" @@ -164,7 +164,7 @@ }, { "cell_type": "markdown", - "id": "0ca26049", + "id": "f2f99df7", "metadata": {}, "source": [ "### Nombre de visites sur l'outil" @@ -173,7 +173,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a4fd6b58", + "id": "d146fa21", "metadata": {}, "outputs": [], "source": [ @@ -184,7 +184,7 @@ }, { "cell_type": "markdown", - "id": "25d61f38", + "id": "5a8347d3", "metadata": {}, "source": [ "### Nombre de visites sur l'étape \"Je ne connais pas\"" @@ -193,7 +193,7 @@ { "cell_type": "code", "execution_count": null, - "id": "75138b55", + "id": "382be506", "metadata": {}, "outputs": [], "source": [ @@ -206,7 +206,7 @@ }, { "cell_type": "markdown", - "id": "6541017d", + "id": "345d152b", "metadata": {}, "source": [ "### Nombre de visites sur l'étape \"Je ne connais pas\" provenant de l'outils \"Trouver sa CC\"" @@ -215,7 +215,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5d00186c", + "id": "caf8ea8d", "metadata": {}, "outputs": [], "source": [ @@ -248,7 +248,7 @@ }, { "cell_type": "markdown", - "id": "dd04c438", + "id": "089c19ea", "metadata": {}, "source": [ "### Nombre de visites ayant effectué une recherche de CC" @@ -257,7 +257,7 @@ { "cell_type": "code", "execution_count": null, - "id": "20b0cf47", + "id": "8eed3613", "metadata": {}, "outputs": [], "source": [ @@ -270,7 +270,7 @@ }, { "cell_type": "markdown", - "id": "cff89d19", + "id": "54bb63ee", "metadata": {}, "source": [ "### Nombre de visites ayant cliqué sur une convention collective" @@ -279,7 +279,7 @@ { "cell_type": "code", "execution_count": null, - "id": "161ccc78", + "id": "79c53985", "metadata": {}, "outputs": [], "source": [ @@ -292,7 +292,7 @@ }, { "cell_type": "markdown", - "id": "dfd44ac9", + "id": "6d9ae05a", "metadata": {}, "source": [ "### Nombre de visites passant par la recherche d'entreprise" @@ -301,7 +301,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a837dd3e", + "id": "c29cecc2", "metadata": {}, "outputs": [], "source": [ @@ -314,7 +314,7 @@ }, { "cell_type": "markdown", - "id": "027c09b0", + "id": "8045c2c6", "metadata": {}, "source": [ "### Nombre de visites passant par la recherche d'entreprise provenant de l'outils \"Trouver sa CC\"" @@ -323,7 +323,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fc49eb23", + "id": "4266ae6e", "metadata": {}, "outputs": [], "source": [ @@ -356,7 +356,7 @@ }, { "cell_type": "markdown", - "id": "4bfed3a0", + "id": "dde85212", "metadata": {}, "source": [ "### Nombre de visite avec une recherche d'entreprise" @@ -365,7 +365,7 @@ { "cell_type": "code", "execution_count": null, - "id": "73fa21e1", + "id": "dcae97de", "metadata": {}, "outputs": [], "source": [ @@ -378,7 +378,7 @@ }, { "cell_type": "markdown", - "id": "c8f6d5d1", + "id": "5c33f735", "metadata": {}, "source": [ "### Nombre de visite avec une sélection d'entreprise" @@ -387,7 +387,7 @@ { "cell_type": "code", "execution_count": null, - "id": "37e7fd43", + "id": "b0f80a8e", "metadata": {}, "outputs": [], "source": [ @@ -401,7 +401,7 @@ { "cell_type": "code", "execution_count": null, - "id": "06e8e7ec", + "id": "4835cfc4", "metadata": {}, "outputs": [], "source": [ @@ -414,7 +414,7 @@ }, { "cell_type": "markdown", - "id": "86ff8ee2", + "id": "cf2e529f", "metadata": {}, "source": [ "### Nombre de visites arrivant sur la CC 3239 à partir de l'écran de recherche par entreprise\n", @@ -429,7 +429,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a81e45ee", + "id": "f893d768", "metadata": {}, "outputs": [], "source": [ @@ -464,7 +464,7 @@ }, { "cell_type": "markdown", - "id": "c1ce4ea6", + "id": "f94d615c", "metadata": {}, "source": [ "### Création du tableau contenant les données de convertion" @@ -473,7 +473,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4d7f4be5", + "id": "17c4159c", "metadata": {}, "outputs": [], "source": [ @@ -500,6 +500,7 @@ " .format(\n", " {col: format_percentages for col in df.columns}, subset=pd.IndexSlice[1, :] # Deuxième ligne\n", " )\n", + " .hide(axis=\"index\")\n", " )\n", "\n", " return styled_df" @@ -507,7 +508,7 @@ }, { "cell_type": "markdown", - "id": "32971ae4", + "id": "7a9329c4", "metadata": {}, "source": [ "### Taux de convertion de la 1er page \"Trouver sa CC\"" @@ -516,21 +517,21 @@ { "cell_type": "code", "execution_count": null, - "id": "7419d538", + "id": "23edfb2b", "metadata": {}, "outputs": [], "source": [ - "data = {\n", + "data1 = {\n", " \"Total visites\": [total_unique_visits, 100],\n", " \"P1 : Conversion\": [total_visits_agreements_from_tool, (total_visits_agreements_from_tool / total_unique_visits * 100)],\n", " \"P2 : Conversion\": [total_visits_enterprises_from_tool, (total_visits_enterprises_from_tool / total_unique_visits * 100)],\n", "}\n", - "display_result(data)" + "display_result(data1)" ] }, { "cell_type": "markdown", - "id": "81d8d033", + "id": "7f459e52", "metadata": {}, "source": [ "### Funnel du parcours \"Je connais ma CC\" \n", @@ -540,21 +541,21 @@ { "cell_type": "code", "execution_count": null, - "id": "f7ce066c", + "id": "ab71b3f8", "metadata": {}, "outputs": [], "source": [ - "data = {\n", + "data2 = {\n", " \"P1 : Visites\": [total_unique_visits_agreements, 100],\n", " \"P1 : Recherches\": [total_agreement_search, (total_agreement_search / total_unique_visits_agreements * 100)],\n", " \"P1 : Click CC\": [total_unique_visits_agreements_select, (total_unique_visits_agreements_select / total_agreement_search * 100)],\n", "}\n", - "display_result(data)" + "display_result(data2)" ] }, { "cell_type": "markdown", - "id": "9de0b93e", + "id": "c75bf9ef", "metadata": {}, "source": [ "### Funnel du parcours \"Je ne connais pas ma CC\"\n", @@ -565,44 +566,55 @@ { "cell_type": "code", "execution_count": null, - "id": "2eece22c", + "id": "bd0a26c4", "metadata": {}, "outputs": [], "source": [ - "data = {\n", + "data3 = {\n", " \"P2 : Visites\": [total_unique_visits_enterprises, 100],\n", " \"P2 : Recherches\": [total_enterprise_search, (total_enterprise_search / total_unique_visits_enterprises * 100)],\n", " \"P2 : Sélections entreprise\": [total_enterprise_select, (total_enterprise_select / total_enterprise_search * 100)],\n", " \"P2 : Click CC\": [total_enterprise_cc_select, (total_enterprise_cc_select / total_enterprise_select * 100)],\n", " \"P2 : 3239\": [total_enterprise_3239, (total_enterprise_3239 / total_unique_visits_enterprises * 100)],\n", "}\n", - "display_result(data)" + "display_result(data3)" ] }, { "cell_type": "markdown", - "id": "b7157a14", + "id": "3da7bfb5", "metadata": {}, "source": [ - "### Sauvegarde du tableau dans un fichier CSV\n", + "### Résultats\n", "\n", - "Le fichier est disponible dans le dossier `explorations/outputs`" + "à copier directement dans le googlesheet" ] }, { "cell_type": "code", "execution_count": null, - "id": "e609c670", - "metadata": {}, + "id": "01b2df45", + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ - "df.to_csv(f\"./outputs/ratio_completion_trouver_sa_convention_collective_{date_debut}_{date_fin}.csv\", index=False, encoding='utf-8')" + "from IPython.display import display\n", + "print(\"Période \",date_debut, date_fin, \"\\n\")\n", + "print(\"\\nTaux de convertion de la 1er page \\\"Trouver sa CC\\\"\")\n", + "display(display_result(data1))\n", + "\n", + "print(\"\\nFunnel du parcours \\\"Je connais ma CC\\\"\")\n", + "display(display_result(data2))\n", + "\n", + "print(\"\\nFunnel du parcours \\\"Je ne connais pas ma CC\\\"\")\n", + "display(display_result(data3))" ] }, { "cell_type": "code", "execution_count": null, - "id": "0725783c", + "id": "5b444757", "metadata": {}, "outputs": [], "source": [] diff --git a/explorations/KPI_PAGE_CONVENTION_COLLECTIVE.ipynb b/explorations/KPI_PAGE_CONVENTION_COLLECTIVE.ipynb index e332d0f..0997aa4 100644 --- a/explorations/KPI_PAGE_CONVENTION_COLLECTIVE.ipynb +++ b/explorations/KPI_PAGE_CONVENTION_COLLECTIVE.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "7a3c12c9", + "id": "5a50e5e2", "metadata": {}, "source": [ "# PAGE - CONVENTION COLLECTIVE\n", @@ -20,7 +20,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fff5c5f0", + "id": "6dce431e", "metadata": {}, "outputs": [], "source": [ @@ -42,7 +42,7 @@ }, { "cell_type": "markdown", - "id": "4c0d7dc7-95af-4ac2-bc7e-1cd633285f8c", + "id": "f511163b", "metadata": {}, "source": [ "### Interval\n", @@ -53,17 +53,17 @@ { "cell_type": "code", "execution_count": null, - "id": "5b356180-62cf-4981-a259-a9d32664f8de", + "id": "0468b575", "metadata": {}, "outputs": [], "source": [ - "date_debut = '2024-10-01'\n", - "date_fin = '2024-10-31'" + "date_debut = '2024-11-01'\n", + "date_fin = '2024-11-30'" ] }, { "cell_type": "markdown", - "id": "6bbb83a2-42cf-4737-a8ef-359e402df210", + "id": "4c388472", "metadata": {}, "source": [ "### Convention collectives supportées\n", @@ -74,16 +74,16 @@ { "cell_type": "code", "execution_count": null, - "id": "9464c8dc-38da-49e9-b1d5-452d6c1e3357", + "id": "85df7544", "metadata": {}, "outputs": [], "source": [ - "cc_ids = ['2511','1596','1597','3127','1404','3043','1517','1527','2941','1043','2609','2596','2614','1483','3239','2264','2216','2148','2098','2120','1996','1979','1702','1672','1516','1518','1606','1501','1505','1486','1480','1351','1266','1147','1090','0843','0675','0292','0275','0176','0086','0044','0016','0029','3248','2420','0413','0787','0573'] # Liste des identifiants des conventions collectives" + "cc_ids = ['2511','1596','1597','3127','1404','3043','1517','1527','2941','1043','2609','2596','2614','1483','3239','2264','2216','2148','2098','2120','1996','1979','1702','1672','1516','1518','1606','1501','1505','1486','1480','1351','1266','1147','1090','843','675','292','275','176','86','44','16','29','3248','2420','413','787','573'] # Liste des identifiants des conventions collectives" ] }, { "cell_type": "markdown", - "id": "dd07dd65", + "id": "8b7ee873", "metadata": {}, "source": [ "### Requête ES" @@ -92,7 +92,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d53a28c2", + "id": "6433f589", "metadata": {}, "outputs": [], "source": [ @@ -100,7 +100,7 @@ "\n", "# Construire dynamiquement les conditions sur les URLs\n", "convention_clauses = [\n", - " {\"prefix\": {\"url\": f\"https://code.travail.gouv.fr/convention-collective/{cc_id}\"}} for cc_id in cc_ids\n", + " {\"prefix\": {\"url\": f\"https://code.travail.gouv.fr/convention-collective/{cc_id}-\"}} for cc_id in cc_ids\n", "]\n", "\n", "# Construire dynamiquement les conditions sur les URLs des contributions\n", @@ -145,7 +145,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b39eb07a", + "id": "15995c83", "metadata": {}, "outputs": [], "source": [ @@ -154,7 +154,7 @@ }, { "cell_type": "markdown", - "id": "f078799e", + "id": "ef26a7ac", "metadata": {}, "source": [ "## Taux de visites où l'utilisateur a cliqué sur une contribution" @@ -162,7 +162,7 @@ }, { "cell_type": "markdown", - "id": "83cc1531-a045-420b-8b78-ee70d13cc457", + "id": "ac282562", "metadata": {}, "source": [ "### Calcul du nombre de visites sur les conventions collectives ayant abouti à un click sur une contribution\n", @@ -177,7 +177,7 @@ { "cell_type": "code", "execution_count": null, - "id": "79604d1a", + "id": "312b6ced", "metadata": {}, "outputs": [], "source": [ @@ -222,7 +222,7 @@ }, { "cell_type": "markdown", - "id": "6f2bd408", + "id": "76028955", "metadata": {}, "source": [ "### Calcul du nombre de visites par convention collective" @@ -231,7 +231,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7fd85d5f", + "id": "1e360ccf", "metadata": {}, "outputs": [], "source": [ @@ -253,7 +253,7 @@ }, { "cell_type": "markdown", - "id": "25f72e2d-75ff-444c-97f3-e6b45aded91d", + "id": "b542c2cd", "metadata": {}, "source": [ "### Ratio du nombre de visites avec convertion pour chaque convention collective" @@ -262,7 +262,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8465d919-58e3-4242-b589-9b3c0de8f413", + "id": "57ac24e5", "metadata": {}, "outputs": [], "source": [ @@ -280,7 +280,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d2516377-9b13-409d-8480-403999fb4ffd", + "id": "f09a7949", "metadata": {}, "outputs": [], "source": [ @@ -297,7 +297,7 @@ }, { "cell_type": "markdown", - "id": "3e35ab76-10cd-4dc4-bed7-4ab73d7a1e29", + "id": "d4c234ea", "metadata": {}, "source": [ "### Sauvegarde du tableau dans un fichier CSV\n", @@ -308,17 +308,27 @@ { "cell_type": "code", "execution_count": null, - "id": "8f33f2a9-5c0c-4834-bf38-e9357a634f3a", + "id": "75325fd5", "metadata": {}, "outputs": [], "source": [ - "merged_df.to_csv(f\"./outputs/ratio_completion_convention_collective_{date_debut}_{date_fin}.csv\", index=False, encoding='utf-8')" + "merged_df.rename(columns={\n", + " 'convention_id': 'CC',\n", + " 'visits_converted': 'Visites contrib',\n", + " 'visits_total': 'Visites total',\n", + " 'ratio': 'ratio'\n", + "}, inplace=True)\n", + "\n", + "# Réorganiser l'ordre des colonnes\n", + "merged_df = merged_df[['CC', 'Visites total', 'Visites contrib', 'ratio']]\n", + "\n", + "merged_df.to_csv(f\"./outputs/ratio_completion_convention_collective_{date_debut}_{date_fin}.csv\", index=False, encoding='utf-8')" ] }, { "cell_type": "code", "execution_count": null, - "id": "0a3e0c92-2a1c-452e-948b-b762622eeb85", + "id": "7116ab2c", "metadata": {}, "outputs": [], "source": [] @@ -340,7 +350,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.10.12" } }, "nbformat": 4,