Nov 16, 2026 | 919 words | 9 min read
11.3.1. PY: Data Analysis and Visualization#
Task #1: NYC Elevator Maps#
Background#
Elevators require regular inspection to ensure functionality and passenger safety. Municipal agencies maintain lists of elevators in their jurisdiction. You have been provided a dataset (“data_NYC_elevators.csv”) of the location and type of elevators currently in use in New York City (which is composed of five boroughs: Manhattan, Queens, the Bronx, Brooklyn, and Staten Island). Use your knowledge of pandas dataframes, plotting, plot formatting, and logic operations to create three figures that display the latitude and longitude of elevators located in New York. Complete this task using the provided data.
List of Registered elevator devices in New York City, Sept 2015
Column |
Description |
|---|---|
DV_DEVICE_NUMBER |
NYC Department of Buildings device identification number |
Device Type |
Type of elevator |
Borough |
Section of NYC: Bronx, Brooklyn, Manhattan, Queens, or Staten Island |
ZIP_CODE |
US postal zip code of elevator location |
LATITUDE |
Elevator latitude (decimal degrees) |
LONGITUDE |
Elevator longitude (decimal degrees) |
Required Files#
Download the Python template
ENGR131_Python_Template.pyand save it as 11_3_1_username.py.Download the data file
data_NYC_elevators.csvand save locally (same file name) for importing and analyzing the data. Do not submit this file to GradescopeCreate and save your figures as PNG files:
Figure 1: 11_3_1_nyc_elevator_map_username.png
Figure 2: 11_3_1_nyc_elevator_map_revised_username.png
Figure 3: 11_3_1_manhattan_elevator_map_username.png
Create and save your filtered Manhattan elevator data as a CSV file: 11_3_1_manhattan_elevator_data_username.csv
Reminder
Review and reference the Python Style Guide to create a professionally formatted code file. For example, remember to provide detailed comments throughout your code so anyone can read them and understand what your program does!
Program Requirements#
Part 1: Load, View and Prep Data for Plotting#
Import the required libraries:
pandas
matplotlib.pyplot
Load “data_NYC_elevators.csv” into a pandas DataFrame called
elev_df.Display:
The first 10 rows of
elev_dfColumn names
Number of rows and columns
Rename the latitude and longitude columns in
elev_dfto “Latitude” and “Longitude”.
Part 2: Plot Figure 1#
Create a scatter plot of latitude vs. longitude of each elevator. The data markers should be blue dots of size 10. Figure size should be 8 x 6.
Use
plt.axis('equal')to set the aspect ratio so that tick mark increments on the x-and y-axis are equal in size to mimic a 2D grid.Export Figure 1 as a PNG using the Figure 1 file name specified in the Required Files section.
Part 3: Clean Data and Plot Figure 2#
After plotting Figure 1, you should see a bad data point.
Write code to remove the bad data point from the data without hardcoding any values. The process of identifying and correcting or removing invalid data points, outliers, and missing values within a dataset is referred to as “cleaning the data”.
Plot the revised latitude and longitude data.
The plot title in Figure 2 must be differentiated from Figure 1 in a meaningful way.
Use green dot data markers (size 1) and increase the figure size to 10 x 8. This will allow you to see some road and park detail on the map.
Export Figure 2 as a PNG using the Figure 2 file name specified in the Required Files section.
Part 4: Filter Manhattan Data and Plot Figure 3#
The zip codes for Manhattan are 10001-10075, -10128, and -10280.
Filter
elev_dfby the latitude and longitude of only the Manhattan elevators without hardcoding any array or linear indices. Store this filtered data into a new DataFrame calledman_elev_df.Display the first 5 rows of
man_elev_dfto ensure the DataFrame only includes data for Manhattan elevators.Plot latitude vs. longitude of the Manhattan subset of elevators in Figure 3. Use purple dot data markers of size 1. You can see road and park detail in the map if you increase the figure size to 10 x 8.
Note: The large rectangular area with almost no elevators is Central Park.
Export Figure 3 as a PNG using the Figure 3 file name specified in the Required Files section.
Display the number of elevators in Manhattan.
Part 5: Write Data to New File#
Write the Manhattan elevator data in man_elev_df to a new CSV using the filename specified in the Required Files section.
Sample Output#
Sample Output
Aside from your figures, ensure that your program output matches the sample output exactly to ensure you receive full points from the auto grader.
Gradescope Submission#
Attention
Before submitting your python file, comment all lines with plt.show() for autograding purposes.
Save Deliverables: Ensure all required assignment files are saved and named exactly as specified in the assignment instructions. If a template file name contains the word
template, replace only that word with your Purdue username. When a task lists more than one deliverable, such as a workbook and a report, submit each deliverable to its own matching Gradescope assignment instead of combining them into one upload.Navigate to Gradescope: Log in to Gradescope. From your Dashboard, open the assignment.
Upload your work: Select the Upload submission method. Drag and drop all required files (or a compressed
.zipfolder) into Gradescope, and select Upload.Confirm Submission: When your upload is successful, you will see a confirmation message on your screen and receive an automated email receipt.
Add Team Members (if applicable): If this is a team assignment, add all team members to the submission. Each teammate should confirm they can see the submission in their own Gradescope account. For help, visit Gradescope’s documentation on adding team members.
Review Autograder Results: Wait a few minutes for the autograder to evaluate the relevant files. Scroll down to view any failed test cases. If you need assistance interpreting the output or errors, ask your teaching team.
Resubmit if Necessary: You can edit your files and select Resubmit as many times as you need before the assignment deadline. Only your final, active submission is graded. (Note: If you need to resubmit, you must upload all required files for the assignment again).
For a detailed walkthrough, review the official Gradescope Submission Guide.