pandas Basic Data Graphs


Pandas uses provides multiple ways to make graphs of the data inside the data frame. It uses matplotlib for that purpose.

The basic graphs have their wrappers for both DataFrame and Series objects:

Line Plot

df = pd.DataFrame({'x': [10, 8, 10, 7, 7, 10, 9, 9],
                   'y': [6, 4, 5, 5, 7, 10, 9, 9]})

Plot of all columns

You can call the same method for a Series object to plot a subset of the Data Frame:


Plot of a data frame subset

Bar Chart

If you want to explore the distribution of your data, you can use the hist() method.


Data Histogram

General method for plotting plot()

All the possible graphs are available through the plot method. The kind of chart is selected by the kind argument.


A Pie Chart

Note In many environments, the pie chart will come out an oval. To make it a circle, use the following:

from matplotlib import pyplot