From the course: Interactive Dashboards with Plotly and Dash

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Solution: Bar charts

Solution: Bar charts

- [Instructor] All right, everybody, our Solution Code is up on the right. Let's go ahead and dive into our notebook. And so we have our ski resorts data read in. You may or may not have chosen to run the info method, but what I did was I went ahead and created a data frame called lift_type_by_country. Because we're going to be using this twice, it seems worth it to build a separate data frame as opposed to do our data manipulation within our bar function itself. So, we're going to group by country, we're going to keep this as a data frame column to make it easier to access, so, as index equals false. We're then going to use the ag method in sum all four of the columns that we're going to be interested in. And then finally, I chose to sort the values in descending order. And so we end up with our data frame that we get the sum of each lift type by country. And so to build our original bar chart, we just specify our data frame, our x column, our y column, and then throw in the title…

Contents