From the course: Python Data Visualization: Create Impactful Visuals, Animations, and Dashboards by Pearson
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Bar plot demo - Python Tutorial
From the course: Python Data Visualization: Create Impactful Visuals, Animations, and Dashboards by Pearson
Bar plot demo
As I mentioned on the slides, there's different kinds of plots you can generate. You already saw the default line plot, we saw the scatter plot, now we're going to look at the bar plot. For this, we need some categorical data. We're going to generate a small data frame with three points of data for two different cities, so LA and San Francisco. For each city, we have three data points. We're going to create our DataFrame by essentially satiating a dictionary with LA as the key for the data for LA, SF as the key of the data for San Francisco. This returns a small DataFrame with three rows and two columns, which we can just set plot and set kind equals bar to return a bar plot. By default, of course, Pandas uses each of the columns as being the different colors of the bars and each row as being the corresponding value. We get three groups of two columns, one for LA and one for San Francisco, so grouped by essentially the row name, so the index of the data frame. Next, we're going to…