Code
import pandas as pd
import numpy as np
# Load the dataset
= "https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-09-17/national_parks.csv"
url = pd.read_csv(url) parks_df
Exploring, Cleaning, and Analyzing National Parks Visitor Data with Pandas
In this collaborative coding exercise, youβll work with a partner to practice importing, cleaning, exploring, and analyzing DataFrames using pandas. Youβll be working with a dataset containing yearly visitor information about national parks in the United States.
Helpful class CheatSheets:
First, letβs import the necessary libraries and load our dataset.
With your partner, explore the DataFrame and perform some initial cleaning. Create cells in your notebook that provide the following information
Use print()
statements and/or f-strings
to create your output in a way that makes it easy to understand your results.
year
is Total
(these are summary rows we donβt need for our analysis).year
column to numeric type.Now, letβs practice some basic filtering and analysis operations:
unit_type
is National Park
)DataFrame.plot()
function.Great job working through these exercises! Youβve practiced importing data, cleaning a dataset, exploring DataFrames, and performing various filtering and analysis operations using pandas. These skills are fundamental to data analysis in Python and will be valuable as you continue to work with more complex datasets.