ISOM 3400 Business Applications Development in Python
Assignment 2
Objective
In the previous assignment, we have completed scraping information about the 2024 U.S. Presidential Primary Election. This time we will use the extracted data to build an informative and compelling Web dashboard. The final deliverable of this group assignment will be a Dash app implemented with certain basic features. This document will show you the requirement of the assignment.
Requirements
- Follow the guidelines stated in this assignment document and complete ALL the tasks. - Only use the libraries covered in this course: Ploty, Dash, Pandas and Json.
- Ensure your submitted program is error-free as it will be checked by clicking the 'Run All' button. - You must submit a programming file in ipynb format.
Marking Criteria
- Ensure correctness and completeness of the displayed data
- Write concise and effective code, avoiding unnecessary repetition
- Make effective use of Python functions
- Write modular code with concise comments
- Use clear and descriptive variable names
- Peer evaluation will be conducted, and the result will affect your final score.
Building a Web app using Dash
Your task is to build a web app that reads the CSV files provided and display the required graphs. Data manipulation using Pandas is necessary for this task. The web app platform consists of three components:
-
A state-level U.S. choropleth map that shows election results among states.
-
Bar charts showing results of delegates earned in each state.
-
State map with county borderlines showing election data in county level.
1. State-level U.S. Choropleth Map
The choropleth map should display the pledged delegates to both party's winning candidates in the primary election of each state. Create a dropdown menu allowing selection of party between Democratic and Republican. The displayed data on the choropleth map should vary accordingly based on the selected party.
Use efficient color scales to show the delegates number acquired in each state. Use a blue theme color to represent the delegates earned by Democratic winning candidates, and red for those earned by Republicans.
Part 1 |
Part 3 |
Part 2 |
|
The hover data displayed for each state should include: State, Party, Winning candidate in the state, Votes gained by the winning candidate, Incumbent information and Delegates. The hover data will be used as input data of the next interactive features.
2. Bar Chart showing delegates gained by candidates
This part is an interactive feature with the choropleth map. When a mouse hovers on a specific state on the choropleth map, this bar chart should display the data of delegates gained by individual candidates in the selected state.
Before any state is selected by mouse hovering, the bar chart should display the number of delegates gained by the winning candidates in all states. This chart should vary according to the selected party from the dropdown menu.
Please follow the above pictures to implement chart components including chart and axis titles, legends and information box triggered by hover data.
3. State map with county borderlines
This is another interactive feature with the U.S. choropleth map. When a mouse hovers over a specific state on the choropleth map, this map should display the state area with borderlines of counties for the selected state. The title of the state map should vary based on the selected state. The color scale of the state map should follow the winner of the county. Same as above, use proper color theme to indicate results of each party. The hover data of this map should include: County, Party, Winning Candidate of the county and Votes gained by the winner.
When county data is not available in a state, the map should still display the state area without county borderlines. Hover data is not required for such state maps. The color scale of the state map should follow the winner of the state. Moreover, before any state is selected by mouse hovering on the U.S. choropleth map, the chart remains blank.
Useful resources provided
prim_state_results.csv
- Storing the required data to plot the state-level choropleth map
prim_county_results.csv
- To provide the ‘FIPS’ data for county-level choropleth map
geojson-counties-fips.json
- The required json file to plot the county-level map
asg2_template.ipynb
- To provide layout template for the Dash app.
Submission Guidelines
All programming files must be in ipynb format. Name the file by your group number, e.g. group_07.ipynb and upload to the assignment module on Canvas for submission.