{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Weekly exercise 7: Simple Pandas exercises\n", "\n", "In this exercise you will analyze some data on occupations." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": false }, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task 1\n", "\n", "- Import the data from [https://raw.githubusercontent.com/justmarkham/DAT8/master/data/u.user](https://raw.githubusercontent.com/justmarkham/DAT8/master/data/u.user) \n", "- Assign it to a variable called `users` \n", "- Output the number of variables and the number of observations \n", "- List the variables \n", "- To take a first look at the data output the first 15 observations " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": false }, "outputs": [], "source": [ "# write your code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task 2\n", "\n", "Compute the mean age per occupation" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": false }, "outputs": [], "source": [ "# write your code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task 3\n", "\n", "Compute the female ratio per occupation and sort it from the most to the least\n", "\n", "Hint: write a function and use *apply* method to convert M/F symbols to integers, if needed." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": false }, "outputs": [], "source": [ "# write your code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task 4\n", "\n", "For each occupation, calculate the minimum and maximum ages" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": false }, "outputs": [], "source": [ "# write your code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task 5\n", "\n", "For each combination of occupation and gender, calculate the mean age" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": false }, "outputs": [], "source": [ "# write your code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task 6\n", "\n", "For each occupation present the percentage of women and men\n", "\n", "Hint: you may find useful functions agg() and div()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide-output": false }, "outputs": [], "source": [ "# write your code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Special thanks to [https://github.com/justmarkham](https://github.com/justmarkham) for sharing the dataset and materials." ] } ], "metadata": { "date": 1632755196.289502, "filename": "exercise07.rst", "kernelspec": { "display_name": "Python", "language": "python3", "name": "python3" }, "title": "Weekly exercise 7: Simple Pandas exercises" }, "nbformat": 4, "nbformat_minor": 4 }