Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Bar and Scatter Plots | Aggregating and Visualizing Data
Data Manipulation using pandas
course content

Contenido del Curso

Data Manipulation using pandas

Data Manipulation using pandas

1. Preprocessing Data: Part I
2. Preprocessing Data: Part II
3. Grouping Data
4. Aggregating and Visualizing Data
5. Joining Data

bookBar and Scatter Plots

There are other kinds of graphs pandas allows us to use for visualization. Among them are boxplots, bar plots, scatter plots, etc. To build a respective plot, apply the .plot() method to selected data, and set the kind parameter to plot type you want to build.

Possible values for the kind parameter are the following.

ValueKind of plot
bar or barhfor bar plots
histfor histogram
scatterfor scatter plots

For instance, to build a scatter plot you also need to set two parameters: x and y. Let's build a scatter plot of total income vs. dwelling price.

12345678
# Importing the library import pandas as pd # Reading the file df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/f2947b09-5f0d-4ad9-992f-ec0b87cd4b3f/data4.csv') # Scatter plot total income vs. dwelling price df.plot(kind = 'scatter', x = 'totinch', y = 'valueh')
copy

The same parameters must be set to build a bar plot. For instance, let's build a bar plot with address on the x-axis and total income on the y-axis for the first 20 dwellings.

12345678
# Importing the library import pandas as pd # Reading the file df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/f2947b09-5f0d-4ad9-992f-ec0b87cd4b3f/data4.csv') # Scatter plot total income vs. dwelling price df.iloc[:20].plot(kind = 'bar', x = 'address', y = 'totinch')
copy

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 4. Capítulo 7
We're sorry to hear that something went wrong. What happened?
some-alt