|
3379 | 3379 | "source": [ |
3380 | 3380 | "### Exercise 3: Grouping Values\n", |
3381 | 3381 | "\n", |
3382 | | - "Find the average year created for each department (Painting & Sculpture, Drawings & Prints, Film, Fluxus Collection, Media & Performance). Group the data using 'Department,' then show a table with the average 'YearCreated' for each department, sorted from oldest to newest.\n", |
| 3382 | + "Find the average year created for each department (Painting & Sculpture, Drawings & Prints, Film, Fluxus Collection, Media & Performance) in the photos collection. Group the data using 'Department,' then show a table with the average 'YearCreated' for each department, sorted from oldest to newest.\n", |
3383 | 3383 | "\n", |
3384 | 3384 | "> Bonus discussion question: does showing the data this way tell the whole story? What other factors could affect the average year the art was created?" |
3385 | 3385 | ] |
|
3581 | 3581 | ], |
3582 | 3582 | "source": [ |
3583 | 3583 | "# Create the groupby object and store in a variable\n", |
3584 | | - "departments = paintings.groupby('Department')\n", |
| 3584 | + "departments = photos.groupby('Department')\n", |
3585 | 3585 | "\n", |
3586 | 3586 | "# Find the mean of each group and sort values by YearCreated\n", |
3587 | 3587 | "departments.mean().sort_values('YearCreated', ascending=True)" |
|
3593 | 3593 | "source": [ |
3594 | 3594 | "### Exercise 4: Group values by two factors\n", |
3595 | 3595 | "\n", |
3596 | | - "Find how many works of art each artist created using different mediums. Group by artist and medium to create a chart that shows how many works of art in the collection by each artist used each medium. " |
| 3596 | + "Find how many works of art each artist created using different mediums. Group by artist and medium to create a chart that shows how many works of art in the photos collection by each artist used each medium. " |
3597 | 3597 | ] |
3598 | 3598 | }, |
3599 | 3599 | { |
|
3626 | 3626 | ], |
3627 | 3627 | "source": [ |
3628 | 3628 | "# Create the groupby object and store in a variable\n", |
3629 | | - "test = paintings.groupby(['Artist', 'Medium'])\n", |
| 3629 | + "test = photos.groupby(['Artist', 'Medium'])\n", |
3630 | 3630 | "\n", |
3631 | 3631 | "# Find the mean of each group and sort values by YearCreated\n", |
3632 | | - "test.size()" |
| 3632 | + "test.mean().sort_values('YearCreated', ascending= False)" |
3633 | 3633 | ] |
3634 | 3634 | }, |
3635 | 3635 | { |
|
0 commit comments