From 03acb304f4ff93b1158e29f9465ee19f9b3f7bcd Mon Sep 17 00:00:00 2001 From: arevelle-ensae Date: Tue, 12 Mar 2024 12:48:42 +0000 Subject: [PATCH] harmonize gender plot --- Sport/Descriptive_statistics/stat_desc_sport.ipynb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sport/Descriptive_statistics/stat_desc_sport.ipynb b/Sport/Descriptive_statistics/stat_desc_sport.ipynb index 1c74b81..e2b0c7e 100644 --- a/Sport/Descriptive_statistics/stat_desc_sport.ipynb +++ b/Sport/Descriptive_statistics/stat_desc_sport.ipynb @@ -822,17 +822,23 @@ "source": [ "def gender_bar(customer_sport):\n", " company_genders = customer_sport.groupby(\"number_company\")[[\"gender_male\", \"gender_female\", \"gender_other\"]].mean().reset_index()\n", + " \n", " # Création du barplot\n", " plt.bar(company_genders[\"number_company\"], company_genders[\"gender_male\"], label = \"Homme\")\n", " plt.bar(company_genders[\"number_company\"], company_genders[\"gender_female\"], \n", " bottom = company_genders[\"gender_male\"], label = \"Femme\")\n", - " \n", + " plt.bar(company_genders[\"number_company\"], company_genders[\"gender_other\"], \n", + " bottom = company_genders[\"gender_male\"] + company_genders[\"gender_female\"], label = \"Inconnu\")\n", " \n", " # Ajout de titres et d'étiquettes\n", " plt.xlabel('Company')\n", " plt.ylabel(\"Part de clients de chaque sexe\")\n", - " plt.title(\"Sexe des clients de chaque compagnie de sport\")\n", + " plt.title(\"Sexe des clients de chaque compagnie de musee\")\n", " plt.legend()\n", + "\n", + " # Définir les étiquettes de l'axe x\n", + " plt.xticks(company_genders[\"number_company\"], [\"{}\".format(i) for i in company_genders[\"number_company\"]])\n", + " \n", " \n", " # Affichage du barplot\n", " plt.show()"