We dont have to apologize for our mental disorder.

We are not here to apologize. I think too often we feel that those of us in the Mental Health community must apologize just for who we are and what we are dealing with but here’s the truth we don’t…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Choropleth Map in Python using Plotly

For the past few weeks, several media sources have been covering the 2020 US elections, each using different ways to present the election results. Drawing inspiration from this, I created a choropleth map of my own using Plotly graphing library. In this article, I will discuss how I generated an interactive choropleth map to visualize the top states in the US for Breweries and Brew Pubs. In addition to this, the map also shows the top-ranked craft beers for each state.

We will be using three datasets:

To create the choropleth map, we need the names of the states and the no. of breweries in each state. The Breweries and Pubs dataset contains information about the name, postal code, and province information of the breweries. However, the province column provides state names for some entries, city names for others, and some entries have abbreviated state names.

In order to maintain the same format for the values in the province column, we keep the state names and abbreviations, and for the other values (city name, county name, etc) we use the postalCode column and the US Zip Code dataset to map an entry to a state name. To keep things simple, all state names to their two letter abbreviations. For entries where postalCode values were missing, the entries were updated manually by checking the address of the brewery.

Once we have our list of states, we create a new list to store the number of breweries in each state. A new DataFrame is created using the two lists above as columns, and then merged with the DataFrame that contains the Top-Ranked Brews for each state. This is the final dataset that will provide data to our Choropleth map.

Now comes the fun part. The graphing library Plotly provides a built-in geometry of USA states, so our job is fairly simple. We use the built-in geometry along with our data to create the Choropleth.

The code above generates this map:

To display information about the top-rated brews, we add hover text to our fig object.

Which gives us this:

Figure 4: Choropleth with Hover Text

Add a comment

Related posts:

BreederDAO Backs the MonkeyLeague Metaverse Big Time

After the last partnership announcements with OLA Gaming Guild and with Rainmaker Games. We are thrilled to announce a new partnership with BreederDAO. By now we’ve covered that-the formation of…

Live it up

A cada dia que se passa mais próximos ficamos da Rússia, há exatos 9 dias o mundo inteiro estará voltado para um só país, tudo que estamos falando aqui colocaremos em prova em uma semana e dois dias…

Send in the Bots

The US should not fund a mission to Mars, but private companies should definitely keep exploring space. These missions should not be done with humans however. With AI and VR technological advances it…