|
883 | 883 | "surveys_df.groupby(['species_id', 'sex'])###" |
884 | 884 | ] |
885 | 885 | }, |
| 886 | + { |
| 887 | + "cell_type": "markdown", |
| 888 | + "id": "9aff1b4a-4bae-4a4f-9e31-cc516daf41e5", |
| 889 | + "metadata": { |
| 890 | + "lang": "fr" |
| 891 | + }, |
| 892 | + "source": [ |
| 893 | + "## Tableaux croisés dynamiques" |
| 894 | + ] |
| 895 | + }, |
| 896 | + { |
| 897 | + "cell_type": "markdown", |
| 898 | + "id": "7ad65751-a3da-4b2b-8f9e-7aeeb44e4f23", |
| 899 | + "metadata": { |
| 900 | + "lang": "en" |
| 901 | + }, |
| 902 | + "source": [ |
| 903 | + "## Pivot tables" |
| 904 | + ] |
| 905 | + }, |
| 906 | + { |
| 907 | + "cell_type": "code", |
| 908 | + "execution_count": null, |
| 909 | + "id": "a4831e8b-2235-46aa-ab5e-1169edf81288", |
| 910 | + "metadata": { |
| 911 | + "lang": "en,fr", |
| 912 | + "tags": [ |
| 913 | + "soln" |
| 914 | + ] |
| 915 | + }, |
| 916 | + "outputs": [], |
| 917 | + "source": [ |
| 918 | + "surveys_df.groupby(\n", |
| 919 | + " ['species_id', 'sex']\n", |
| 920 | + ")['hindfoot_length'].median().unstack().head()" |
| 921 | + ] |
| 922 | + }, |
| 923 | + { |
| 924 | + "cell_type": "code", |
| 925 | + "execution_count": null, |
| 926 | + "id": "7c22df2f-041f-46d0-9704-c54da1e7125e", |
| 927 | + "metadata": { |
| 928 | + "lang": "en,fr", |
| 929 | + "tags": [ |
| 930 | + "exer" |
| 931 | + ] |
| 932 | + }, |
| 933 | + "outputs": [], |
| 934 | + "source": [ |
| 935 | + "surveys_df.groupby(\n", |
| 936 | + " ['species_id', 'sex']\n", |
| 937 | + ")['hindfoot_length'].median()#.unstack()#.head()" |
| 938 | + ] |
| 939 | + }, |
| 940 | + { |
| 941 | + "cell_type": "code", |
| 942 | + "execution_count": null, |
| 943 | + "id": "d6ea30c5-4904-4efa-8111-611eba05f986", |
| 944 | + "metadata": { |
| 945 | + "lang": "en,fr" |
| 946 | + }, |
| 947 | + "outputs": [], |
| 948 | + "source": [ |
| 949 | + "surveys_df.pivot_table(\n", |
| 950 | + " values='hindfoot_length',\n", |
| 951 | + " index='species_id',\n", |
| 952 | + " columns='sex',\n", |
| 953 | + " aggfunc='median').head()" |
| 954 | + ] |
| 955 | + }, |
886 | 956 | { |
887 | 957 | "cell_type": "markdown", |
888 | 958 | "id": "a96f6358-ba62-4a01-b95f-df05e771fceb", |
|
907 | 977 | "* **Grouper selon les valeurs** d'une ou plusieurs colonnes :\n", |
908 | 978 | " * `groupby(nom_col)`\n", |
909 | 979 | " * `groupby([nom_col1, nom_col2])`\n", |
910 | | - "* **Transformer le DataFrame** : `unstack()`" |
| 980 | + "* **Tableaux croisés dynamiques**\n", |
| 981 | + " * Transformation selon les valeurs de l'index : `unstack()`\n", |
| 982 | + " * Aggrégation dans un tableau croisé dynamique : `pivot_table()`" |
911 | 983 | ] |
912 | 984 | }, |
913 | 985 | { |
|
934 | 1006 | "* **Grouping by values** of one or many columns:\n", |
935 | 1007 | " * `groupby(column_name)`\n", |
936 | 1008 | " * `groupby([column_name1, column_name2])`\n", |
937 | | - "* **Reshaping a DataFrame** from values in the index: `unstack()`" |
| 1009 | + "* **Pivot tables**\n", |
| 1010 | + " * Reshaping a DataFrame from values in the index: `unstack()`\n", |
| 1011 | + " * Aggregation in a pivot table: `pivot_table()`" |
938 | 1012 | ] |
939 | 1013 | }, |
940 | 1014 | { |
|
0 commit comments