Book Image

Learning Pandas

By : Michael Heydt
Book Image

Learning Pandas

By: Michael Heydt

Overview of this book

Table of Contents (19 chapters)
Learning pandas
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Common plots used in statistical analyses


Having seen how to create, lay out, and annotate time-series charts, we will now look at creating a number of charts, other than time series that are commonplace in presenting statistical information.

Bar plots

Bar plots are useful in order to visualize the relative differences in values of non time-series data. Bar plots can be created using the kind='bar' parameter of the .plot() method:

In [24]:
   # make a bar plot
   # create a small series of 10 random values centered at 0.0
   np.random.seed(seedval)
   s = pd.Series(np.random.rand(10) - 0.5)
   # plot the bar chart
   s.plot(kind='bar');

If the data being plotted consists of multiple columns, a multiple series bar plot will be created:

In [25]:
   # draw a multiple series bar chart
   # generate 4 columns of 10 random values
   np.random.seed(seedval)
   df2 = pd.DataFrame(np.random.rand(10, 4), 
                      columns=['a', 'b', 'c', 'd'])
   # draw the multi-series bar chart
   df2...