Task 4 - Pandas#
In this lab you work on applying your new Python skills to work with data - finally!
Objectives#
In this lab you will:
Practice working with data using the pandas package
Practice some data wrangling mathematical operations.
Practice working with the seaborn package.
Practice creating data visualizations.
# Usually all the import statements are at the top of the file
import pandas as pd
import seaborn as sns
import numpy as np
import os
import matplotlib.pyplot as plt
Task 4: Working with data using pandas#
In this part of the lab, we will practice loading in a sample data set using pandas, and doing some basic operations.
4.1: Load in the data#
There is a CSV file (pokemon.csv
) inside a directory called data
within the lab3A
directory.
Your task is to use the pandas read_csv()
function to read this dataset, assign it to a dataframe called df
, and then print its head
also known as the first 5 lines of the dataframe.
Hint: don’t forget to first import pandas as pd
to use read_csv
and other pandas function.
### Your solution here
4.2: How many total pokemon are there in the dataset?#
Make sure to use the dataframe.count()
function to print the total number of entries in each column of the dataframe before you answer!
### Your solution here
4.3: Create a new dataframe df2
that only includes the Pokemon from the first generation.#
Hint: Remember that you can subset dataframes using the []
syntax. More on this here
### Your solution here
4.4: Print ONLY the mean HP, Attack, Defense, and Speed of all pokemon in the first generation using pandas functions#
### Your solution here