Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added your-code/.DS_Store
Binary file not shown.
276 changes: 276 additions & 0 deletions your-code/.ipynb_checkpoints/challenge-1-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Challenge 1\n",
"\n",
"In this challenge you will be working on **Pokemon**. You will answer a series of questions in order to practice dataframe calculation, aggregation, and transformation.\n",
"\n",
"![Pokemon](../images/pokemon.jpg)\n",
"\n",
"Follow the instructions below and enter your code.\n",
"\n",
"#### Import all required libraries."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# import libraries"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Import data set.\n",
"\n",
"Read the dataset `pokemon.csv` into a dataframe called `pokemon`.\n",
"\n",
"*Data set attributed to [Alberto Barradas](https://www.kaggle.com/abcsds/pokemon/)*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# import dataset"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Print first 10 rows of `pokemon`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When you look at a data set, you often wonder what each column means. Some open-source data sets provide descriptions of the data set. In many cases, data descriptions are extremely useful for data analysts to perform work efficiently and successfully.\n",
"\n",
"For the `Pokemon.csv` data set, fortunately, the owner provided descriptions which you can see [here](https://www.kaggle.com/abcsds/pokemon/home). For your convenience, we are including the descriptions below. Read the descriptions and understand what each column means. This knowledge is helpful in your work with the data.\n",
"\n",
"| Column | Description |\n",
"| --- | --- |\n",
"| # | ID for each pokemon |\n",
"| Name | Name of each pokemon |\n",
"| Type 1 | Each pokemon has a type, this determines weakness/resistance to attacks |\n",
"| Type 2 | Some pokemon are dual type and have 2 |\n",
"| Total | A general guide to how strong a pokemon is |\n",
"| HP | Hit points, or health, defines how much damage a pokemon can withstand before fainting |\n",
"| Attack | The base modifier for normal attacks (eg. Scratch, Punch) |\n",
"| Defense | The base damage resistance against normal attacks |\n",
"| SP Atk | Special attack, the base modifier for special attacks (e.g. fire blast, bubble beam) |\n",
"| SP Def | The base damage resistance against special attacks |\n",
"| Speed | Determines which pokemon attacks first each round |\n",
"| Generation | Number of generation |\n",
"| Legendary | True if Legendary Pokemon False if not |"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Obtain the distinct values across `Type 1` and `Type 2`.\n",
"\n",
"Exctract all the values in `Type 1` and `Type 2`. Then create an array containing the distinct values across both fields."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Cleanup `Name` that contain \"Mega\".\n",
"\n",
"If you have checked out the pokemon names carefully enough, you should have found there are junk texts in the pokemon names which contain \"Mega\". We want to clean up the pokemon names. For instance, \"VenusaurMega Venusaur\" should be \"Mega Venusaur\", and \"CharizardMega Charizard X\" should be \"Mega Charizard X\"."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# your code here\n",
"\n",
"\n",
"# test transformed data\n",
"pokemon.head(10)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Create a new column called `A/D Ratio` whose value equals to `Attack` devided by `Defense`.\n",
"\n",
"For instance, if a pokemon has the Attack score 49 and Defense score 49, the corresponding `A/D Ratio` is 49/49=1."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Identify the pokemon with the highest `A/D Ratio`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Identify the pokemon with the lowest A/D Ratio."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Create a new column called `Combo Type` whose value combines `Type 1` and `Type 2`.\n",
"\n",
"Rules:\n",
"\n",
"* If both `Type 1` and `Type 2` have valid values, the `Combo Type` value should contain both values in the form of `<Type 1> <Type 2>`. For example, if `Type 1` value is `Grass` and `Type 2` value is `Poison`, `Combo Type` will be `Grass-Poison`.\n",
"\n",
"* If `Type 1` has valid value but `Type 2` is not, `Combo Type` will be the same as `Type 1`. For example, if `Type 1` is `Fire` whereas `Type 2` is `NaN`, `Combo Type` will be `Fire`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Identify the pokemon whose `A/D Ratio` are among the top 5."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### For the 5 pokemon printed above, aggregate `Combo Type` and use a list to store the unique values.\n",
"\n",
"Your end product is a list containing the distinct `Combo Type` values of the 5 pokemon with the highest `A/D Ratio`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### For each of the `Combo Type` values obtained from the previous question, calculate the mean scores of all numeric fields across all pokemon.\n",
"\n",
"Your output should look like below:\n",
"\n",
"![Aggregate](../images/aggregated-mean.png)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading