|
410 | 410 | }, |
411 | 411 | "source": [ |
412 | 412 | "### Exercice - Une sélection de données\n", |
413 | | - "Calculez la moyenne des **longueurs d'arrière-pieds** et\n", |
| 413 | + "Obtenez la moyenne des **longueurs d'arrière-pieds** et\n", |
414 | 414 | "des **poids** de chaque **espèce** de `'NL'` à `'PB'` :\n", |
415 | 415 | "\n", |
416 | 416 | "1. Commencez par sélectionner uniquement les colonnes requises.\n", |
|
427 | 427 | }, |
428 | 428 | "source": [ |
429 | 429 | "### Exercise - Selecting data\n", |
430 | | - "Calculate the average **hindfoot lengths** and\n", |
| 430 | + "Get the average **hindfoot lengths** and\n", |
431 | 431 | "**weights** of each **species** from `'NL'` to `'PB'`:\n", |
432 | 432 | "\n", |
433 | 433 | "1. Start by selecting only the required columns.\n", |
|
967 | 967 | "avg_by_site_sex.tail()" |
968 | 968 | ] |
969 | 969 | }, |
970 | | - { |
971 | | - "cell_type": "code", |
972 | | - "execution_count": null, |
973 | | - "id": "a9657ac7-81af-4cd0-bed3-621834048043", |
974 | | - "metadata": { |
975 | | - "lang": "fr", |
976 | | - "tags": [ |
977 | | - "soln" |
978 | | - ] |
979 | | - }, |
980 | | - "outputs": [], |
981 | | - "source": [ |
982 | | - "# Transformer les catégories de sexe en noms de colonne\n", |
983 | | - "table_site_sexe = moy_par_site_sexe.unstack()\n", |
984 | | - "\n", |
985 | | - "# L'entête contient deux niveaux. Pour enlever le premier niveau :\n", |
986 | | - "table_site_sexe.columns = table_site_sexe.columns.droplevel()\n", |
987 | | - "table_site_sexe.tail()" |
988 | | - ] |
989 | | - }, |
990 | | - { |
991 | | - "cell_type": "code", |
992 | | - "execution_count": null, |
993 | | - "id": "8571c63a-6c73-43eb-89ed-e772e1e9fd1e", |
994 | | - "metadata": { |
995 | | - "lang": "fr", |
996 | | - "tags": [ |
997 | | - "exer" |
998 | | - ] |
999 | | - }, |
1000 | | - "outputs": [], |
1001 | | - "source": [ |
1002 | | - "# Transformer les catégories de sexe en noms de colonne\n", |
1003 | | - "table_site_sexe = moy_par_site_sexe.unstack()\n", |
1004 | | - "\n", |
1005 | | - "# L'entête contient deux niveaux. Pour enlever le premier niveau :\n", |
1006 | | - "# table_site_sexe.columns = table_site_sexe.columns.droplevel()\n", |
1007 | | - "table_site_sexe.tail()" |
1008 | | - ] |
1009 | | - }, |
1010 | | - { |
1011 | | - "cell_type": "code", |
1012 | | - "execution_count": null, |
1013 | | - "id": "f9deccad-37a1-4489-b5d9-e3f8284dda00", |
1014 | | - "metadata": { |
1015 | | - "lang": "en", |
1016 | | - "tags": [ |
1017 | | - "soln" |
1018 | | - ] |
1019 | | - }, |
1020 | | - "outputs": [], |
1021 | | - "source": [ |
1022 | | - "# Transform categorical values into columns\n", |
1023 | | - "table_site_sex = avg_by_site_sex.unstack()\n", |
1024 | | - "\n", |
1025 | | - "# The legend header contains two levels. To remove the first level:\n", |
1026 | | - "table_site_sex.columns = table_site_sex.columns.droplevel()\n", |
1027 | | - "table_site_sex.tail()" |
1028 | | - ] |
1029 | | - }, |
1030 | | - { |
1031 | | - "cell_type": "code", |
1032 | | - "execution_count": null, |
1033 | | - "id": "fc477d1c-0cdb-4312-b505-6afbaa5209f4", |
1034 | | - "metadata": { |
1035 | | - "lang": "en", |
1036 | | - "tags": [ |
1037 | | - "exer" |
1038 | | - ] |
1039 | | - }, |
1040 | | - "outputs": [], |
1041 | | - "source": [ |
1042 | | - "# Transform categorical values into columns\n", |
1043 | | - "table_site_sex = avg_by_site_sex.unstack()\n", |
1044 | | - "\n", |
1045 | | - "# The legend header contains two levels. To remove the first level:\n", |
1046 | | - "# table_site_sex.columns = table_site_sex.columns.droplevel()\n", |
1047 | | - "table_site_sex.tail()" |
1048 | | - ] |
1049 | | - }, |
1050 | | - { |
1051 | | - "cell_type": "code", |
1052 | | - "execution_count": null, |
1053 | | - "id": "dc01d427-8519-4602-8522-e9d363953836", |
1054 | | - "metadata": { |
1055 | | - "lang": "fr" |
1056 | | - }, |
1057 | | - "outputs": [], |
1058 | | - "source": [ |
1059 | | - "# Créer le bar plot\n", |
1060 | | - "table_site_sexe.plot(kind='bar')" |
1061 | | - ] |
1062 | | - }, |
1063 | | - { |
1064 | | - "cell_type": "code", |
1065 | | - "execution_count": null, |
1066 | | - "id": "f9139ad6-7662-46bf-98d5-b3c5bfadd9a7", |
1067 | | - "metadata": { |
1068 | | - "lang": "en" |
1069 | | - }, |
1070 | | - "outputs": [], |
1071 | | - "source": [ |
1072 | | - "# And we can make a bar plot from this:\n", |
1073 | | - "table_site_sex.plot(kind='bar')" |
1074 | | - ] |
1075 | | - }, |
1076 | 970 | { |
1077 | 971 | "cell_type": "markdown", |
1078 | 972 | "id": "a2584e88-879e-4a8f-bcdc-b6bd0cba34a2", |
|
0 commit comments