harmonize gender plot

This commit is contained in:
Alexis REVELLE 2024-03-12 12:48:42 +00:00
parent 8acc32de70
commit 03acb304f4

View File

@ -822,18 +822,24 @@
"source": [ "source": [
"def gender_bar(customer_sport):\n", "def gender_bar(customer_sport):\n",
" company_genders = customer_sport.groupby(\"number_company\")[[\"gender_male\", \"gender_female\", \"gender_other\"]].mean().reset_index()\n", " company_genders = customer_sport.groupby(\"number_company\")[[\"gender_male\", \"gender_female\", \"gender_other\"]].mean().reset_index()\n",
" \n",
" # Création du barplot\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_male\"], label = \"Homme\")\n",
" plt.bar(company_genders[\"number_company\"], company_genders[\"gender_female\"], \n", " plt.bar(company_genders[\"number_company\"], company_genders[\"gender_female\"], \n",
" bottom = company_genders[\"gender_male\"], label = \"Femme\")\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", " \n",
" # Ajout de titres et d'étiquettes\n", " # Ajout de titres et d'étiquettes\n",
" plt.xlabel('Company')\n", " plt.xlabel('Company')\n",
" plt.ylabel(\"Part de clients de chaque sexe\")\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", " plt.legend()\n",
"\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", " # Affichage du barplot\n",
" plt.show()" " plt.show()"
] ]