Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mastering pandas. - Second Edition

You're reading from  Mastering pandas. - Second Edition

Product type Book
Published in Oct 2019
Publisher
ISBN-13 9781789343236
Pages 674 pages
Edition 2nd Edition
Languages
Author (1):
Ashish Kumar Ashish Kumar
Profile icon Ashish Kumar

Table of Contents (21) Chapters

Preface Section 1: Overview of Data Analysis and pandas
Introduction to pandas and Data Analysis Installation of pandas and Supporting Software Section 2: Data Structures and I/O in pandas
Using NumPy and Data Structures with pandas I/Os of Different Data Formats with pandas Section 3: Mastering Different Data Operations in pandas
Indexing and Selecting in pandas Grouping, Merging, and Reshaping Data in pandas Special Data Operations in pandas Time Series and Plotting Using Matplotlib Section 4: Going a Step Beyond with pandas
Making Powerful Reports In Jupyter Using pandas A Tour of Statistics with pandas and NumPy A Brief Tour of Bayesian Statistics and Maximum Likelihood Estimates Data Case Studies Using pandas The pandas Library Architecture pandas Compared with Other Tools A Brief Tour of Machine Learning Other Books You May Enjoy

Making Powerful Reports In Jupyter Using pandas

pandas and Jupyter Notebook can be used to create nicely formatted output, reports, and/or tutorials that are easy to share with a wide range of audiences. In this chapter, we will look into the application of a range of styles and the formatting options that pandas provides. We will also understand how to create dashboards and reports in Jupyter Notebook.

The following topics will be covered in this chapter:

  • pandas styling
  • Navigating Jupyter Notebook
  • Making reports using Jupyter Notebooks

pandas styling

pandas allow for a wide variety of operations to be performed on DataFrames, making it easier to handle structured data. Another intriguing property of DataFrames is that they allow us to format and style regular rows and columns in tabular data. These styling properties help enhance the readability of tabular data. The Dataframe.style method returns a Styler object. Any formatting to be applied before displaying a DataFrame can be applied over this Styler object. Styling can be done either with in-built functions that have predefined rules for formatting or with user-defined rules.

Let's consider the following DataFrames so that we can take a look at pandas' styling properties:

  df = pd.read_csv("titanic.csv")
  df

The following screenshot shows the preceding DataFrame loaded into Jupyter Notebook:

DataFrame loaded into Jupyter Notebook...

Navigating Jupyter Notebook

Jupyter Notebook, known as IPython Notebook previously, is a wonderful tool for reporting. It allows us to integrate regular code with rich styling, formatting, markdown, and special text such as equation plots and live coding. This section will help you understand the essence of a Jupyter Notebook.

Jupyter Notebook can be launched through Anaconda Navigator or from the Terminal using the Jupyter Notebook command. It opens in the browser. The following window opens on startup:

Figure 9.20: Startup screen once a Jupyter Notebook loads up

A Jupyter Notebook can be created in any of the folders in the directory. The New option creates a new notebook, folder, or Terminal. The most interesting feature of this option is that it allows us to shift between multiple Conda environments with ease. For example, both Python 2 and Python 3 environments can be accessed...

Summary

This chapter focused on three main themes: styling and result formatting options in pandas, creating interactive dashboards in Jupyter Notebook, and exploring formatting and typesetting options in Jupyter Notebook to create powerful reports.

Output formatting such as conditional formatting, bold and italics output, highlighting certain sections, and so on can be done by styling options in pandas. Basic interactive dashboards can be created in Jupyter Notebook. LaTex, and MathJax and provide powerful typesetting and markdown options for writing equations and formatting text. Reports can be shared as ipynb files on GitHub, and can be viewed in an online viewer called NbViewer. Jupyter Hub is the multi-user server-based deployment method.

In the next chapter, we will look at how pandas can be used to perform statistical calculations using packages; we will also perform calculations...

lock icon The rest of the chapter is locked
You have been reading a chapter from
Mastering pandas. - Second Edition
Published in: Oct 2019 Publisher: ISBN-13: 9781789343236
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}