Shiny for Python Choropleth Map
Mapping US gun violence mass shootings with ipyleaflet in Shiny for Python
--
Preamble
The purpose of this blog is two-fold:
- To showcase building a choropleth map application in Shiny for Python.
- To elucidate the location of deaths and injuries resulting from mass shootings within the US.
I had been thinking of creating an app on gun violence and mass shootings and figured with Shiny recently becoming available in Python, it was a good opportunity to give it a try.
That said, Shiny for Python is still in the development phase, many of the packages I attempted to use just aren’t accepted yet, so I had to find some work arounds. In fact as of December 2022 on their website it says:
“Note! Shiny for Python is currently in Alpha. It may be unstable, and the API may change. We’re excited to hear your feedback, but please don’t use it for production applications just yet!”
So please take note, and stick with RShiny if you are interested production applications.
Data
Mass Shooting
I decided to utilize the Gun Violence Archive (GVA) dataset on mass shootings from 2019–2022. GVA is a non-profit dedicated to providing free online public access to accurate information about gun-related violence in the United States.
It is important to understand they define mass shootings as:
“GVA uses a purely statistical threshold to define mass shooting based ONLY on the numeric value of 4 or more shot or killed, not including the shooter. GVA does not parse the definition to remove any subcategory of shooting. To that end we don’t exclude, set apart, caveat, or differentiate victims based upon the circumstances in which they were shot. GVA believes that equal importance is given to the counting of those injured as well as killed in a mass shooting incident.”
For complete info on their methodology please see the about section.
Gun Laws
I wanted to investigate the correlation between gun laws and the frequency of mass shooting events, so I downloaded…