This notebook is an exercise in the Data Visualization course. You can reference the tutorial at this link.


In this exercise, you will use your new knowledge to propose a solution to a real-world scenario. To succeed, you will need to import data into Python, answer questions using the data, and generate line charts to understand patterns in the data.

Scenario

You have recently been hired to manage the museums in the City of Los Angeles. Your first project focuses on the four museums pictured in the images below.

ex1_museums

You will leverage data from the Los Angeles Data Portal that tracks monthly visitors to each museum.

ex1_xlsx

Setup

Run the next cell to import and configure the Python libraries that you need to complete the exercise.

The questions below will give you feedback on your work. Run the following cell to set up the feedback system.

Step 1: Load the data

Your first assignment is to read the LA Museum Visitors data file into museum_data. Note that:

To help with this, you may find it useful to revisit some relevant code from the tutorial, which we have pasted below:

# Path of the file to read
spotify_filepath = "../input/spotify.csv"

# Read the file into a variable spotify_data
spotify_data = pd.read_csv(spotify_filepath, index_col="Date", parse_dates=True)

The code you need to write now looks very similar!

Step 2: Review the data

Use a Python command to print the last 5 rows of the data.

The last row (for 2018-11-01) tracks the number of visitors to each museum in November 2018, the next-to-last row (for 2018-10-01) tracks the number of visitors to each museum in October 2018, and so on.

Use the last 5 rows of the data to answer the questions below.

Step 3: Convince the museum board

The Firehouse Museum claims they ran an event in 2014 that brought an incredible number of visitors, and that they should get extra budget to run a similar event again. The other museums think these types of events aren't that important, and budgets should be split purely based on recent visitors on an average day.

To show the museum board how the event compared to regular traffic at each museum, create a line chart that shows how the number of visitors to each museum evolved over time. Your figure should have four lines (one for each museum).

(Optional) Note: If you have some prior experience with plotting figures in Python, you might be familiar with the plt.show() command. If you decide to use this command, please place it after the line of code that checks your answer (in this case, place it after step_3.check() below) -- otherwise, the checking code will return an error!

Step 4: Assess seasonality

When meeting with the employees at Avila Adobe, you hear that one major pain point is that the number of museum visitors varies greatly with the seasons, with low seasons (when the employees are perfectly staffed and happy) and also high seasons (when the employees are understaffed and stressed). You realize that if you can predict these high and low seasons, you can plan ahead to hire some additional seasonal employees to help out with the extra work.

Part A

Create a line chart that shows how the number of visitors to Avila Adobe has evolved over time. (If your code returns an error, the first thing that you should check is that you've spelled the name of the column correctly! You must write the name of the column exactly as it appears in the dataset.)

Part B

Does Avila Adobe get more visitors:

Using this information, when should the museum staff additional seasonal employees?

Keep going

Move on to learn about bar charts and heatmaps with a new dataset!


Have questions or comments? Visit the Learn Discussion forum to chat with other Learners.