|
402 | 402 | " print(f'The problem: {error}')" |
403 | 403 | ] |
404 | 404 | }, |
| 405 | + { |
| 406 | + "cell_type": "markdown", |
| 407 | + "id": "73db3a2a-4d6f-4342-b408-9c4a4f116759", |
| 408 | + "metadata": { |
| 409 | + "lang": "fr" |
| 410 | + }, |
| 411 | + "source": [ |
| 412 | + "### Exercice - Une sélection de données\n", |
| 413 | + "Calculez la moyenne des **longueurs d'arrière-pieds** et\n", |
| 414 | + "des **poids** de chaque **espèce** de `'NL'` à `'PB'` :\n", |
| 415 | + "\n", |
| 416 | + "1. Commencez par sélectionner uniquement les colonnes requises.\n", |
| 417 | + "2. À la fin, sélectionnez les lignes de `'NL'` à `'PB'`.\n", |
| 418 | + "\n", |
| 419 | + "(3 min.)" |
| 420 | + ] |
| 421 | + }, |
| 422 | + { |
| 423 | + "cell_type": "markdown", |
| 424 | + "id": "44cbc36a-59bd-4e78-8f8e-23e4b7073326", |
| 425 | + "metadata": { |
| 426 | + "lang": "en" |
| 427 | + }, |
| 428 | + "source": [ |
| 429 | + "### Exercise - Selecting data\n", |
| 430 | + "Calculate the average **hindfoot lengths** and\n", |
| 431 | + "**weights** of each **species** from `'NL'` to `'PB'`:\n", |
| 432 | + "\n", |
| 433 | + "1. Start by selecting only the required columns.\n", |
| 434 | + "2. At the end, select the rows from `'NL'` to `'PB'`.\n", |
| 435 | + "\n", |
| 436 | + "(3 min.)" |
| 437 | + ] |
| 438 | + }, |
| 439 | + { |
| 440 | + "cell_type": "code", |
| 441 | + "execution_count": null, |
| 442 | + "id": "5afff414-4369-4d3d-b7ee-8aa2d0a62664", |
| 443 | + "metadata": { |
| 444 | + "lang": "fr", |
| 445 | + "tags": [ |
| 446 | + "soln" |
| 447 | + ] |
| 448 | + }, |
| 449 | + "outputs": [], |
| 450 | + "source": [ |
| 451 | + "colonnes = ['species_id', 'hindfoot_length', 'weight']\n", |
| 452 | + "surveys_df[colonnes].groupby('species_id').mean().loc['NL':'PB', :]" |
| 453 | + ] |
| 454 | + }, |
| 455 | + { |
| 456 | + "cell_type": "code", |
| 457 | + "execution_count": null, |
| 458 | + "id": "d7a08eaf-4ab2-4b57-b8e2-aca33f42b8b3", |
| 459 | + "metadata": { |
| 460 | + "lang": "fr", |
| 461 | + "tags": [ |
| 462 | + "exer" |
| 463 | + ] |
| 464 | + }, |
| 465 | + "outputs": [], |
| 466 | + "source": [ |
| 467 | + "colonnes = ['species_id', 'hindfoot_length', 'weight']\n", |
| 468 | + "surveys_df###.groupby('species_id').mean()###" |
| 469 | + ] |
| 470 | + }, |
| 471 | + { |
| 472 | + "cell_type": "code", |
| 473 | + "execution_count": null, |
| 474 | + "id": "ecc078ee-438b-4966-8f23-243a297c4f16", |
| 475 | + "metadata": { |
| 476 | + "lang": "en", |
| 477 | + "tags": [ |
| 478 | + "soln" |
| 479 | + ] |
| 480 | + }, |
| 481 | + "outputs": [], |
| 482 | + "source": [ |
| 483 | + "columns = ['species_id', 'hindfoot_length', 'weight']\n", |
| 484 | + "surveys_df[columns].groupby('species_id').mean().loc['NL':'PB', :]" |
| 485 | + ] |
| 486 | + }, |
| 487 | + { |
| 488 | + "cell_type": "code", |
| 489 | + "execution_count": null, |
| 490 | + "id": "cdb14a63-1037-4bc7-b7e8-48d273d2b2ac", |
| 491 | + "metadata": { |
| 492 | + "lang": "en", |
| 493 | + "tags": [ |
| 494 | + "exer" |
| 495 | + ] |
| 496 | + }, |
| 497 | + "outputs": [], |
| 498 | + "source": [ |
| 499 | + "columns = ['species_id', 'hindfoot_length', 'weight']\n", |
| 500 | + "surveys_df###.groupby('species_id').mean()###" |
| 501 | + ] |
| 502 | + }, |
405 | 503 | { |
406 | 504 | "cell_type": "markdown", |
407 | 505 | "id": "8f2ce1e8-85cd-4df4-b129-ae9326e305dd", |
|
0 commit comments