Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Learning Jupyter 5
Learning Jupyter 5

Learning Jupyter 5: Explore interactive computing using Python, Java, JavaScript, R, Julia, and JupyterLab , Second Edition

eBook
$9.99 $35.99
Paperback
$43.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Learning Jupyter 5

Jupyter Python Scripting

Jupyter was originally IPython, an interactive version of Python to be used as a development environment. As such, most of the features of Python are available to you when developing your Notebook.

In this chapter, we will cover the following topics:

  •  Basic Python scripting
  •  Python dataset access (from a library)
  •  Python pandas
  •  Python graphics
  •  Python random numbers

Basic Python in Jupyter

We must open a Python section of our Notebook to use Python coding. So, start your Notebook, and then in the upper-right menu, select Python 3:

This will open a Python window to work in:

As mentioned in the previous chapter, the new window shows an empty cell so that you can enter Python code.

Let's give the new work area a name, Learning Jupyter 5, Chapter 2. Autosave should be on (as you can see next to the title). With an accurate name, we can find this section again easily from the Notebook home page. If you select your browser's Home tab and refresh it, you will see this new window name being displayed:

Note that it has an Notebook icon versus a folder icon. The extension that's automatically assigned is .ipynb (Python Notebook). And, since the item is in a browser in a Jupyter environment, it is marked as running. There is...

Python data access in Jupyter

Now that we have seen how Python works in Jupyter, including the underlying encoding, how does Python access a large dataset of work in Jupyter?

I started another view for pandas, using Python data access as the name. From here, we will read in a large dataset and compute some standard statistics on the data. We are interested in seeing how we use pandas in Jupyter, how well the script performs, and what information is stored in the metadata (especially if it is a larger dataset).

Our script accesses the iris dataset that is built-in to one of the Python packages. All we are looking to do is read in a slightly large number of items and calculate some basic operations on the dataset. We are really interested to see how much of the data is cached in the .pynb file.

The Python code is as follows: 

# import the datasets package 
from sklearn import...

Python pandas in Jupyter

One of the most widely used features of Python is pandas. The pandas are built-in libraries of data analysis packages that can be used freely. In this example, we will develop a Python script that uses pandas to see if there is any affect of using them in Jupyter.

I am using the Titanic dataset from https://www.kaggle.com/c/titanic/data. I am sure that the same data is available from a variety of sources.

Note that you have to sign up for Kaggle in order to download the data. It's free.

Here is our Python script that we want to run in Jupyter:

from pandas import * 
training_set = read_csv('train.csv') 
training_set.head() 
male = training_set[training_set.Sex == 'male'] 
female = training_set[training_set.Sex =='female'] 
womens_survival_rate = float(sum(female.Survived))/len(female) 
mens_survival_rate = float(sum(male...

Python graphics in Jupyter

How do Python graphics work in Jupyter?

I started another view for this named Python graphics so as to distinguish the work.

If we were to build a sample dataset of baby names and the number of births in a year of that name, we could then plot the data.

The Python coding is simple:

import pandas 
import matplotlib 
 
%matplotlib inline 
 
# define our two columns of data 
baby_name = ['Alice','Charles','Diane','Edward'] 
number_births = [96, 155, 66, 272] 
 
# create a dataset from the to sets 
dataset = list(zip(baby_name,number_births)) 
dataset 
 
# create a Python dataframe from the dataset 
df = pandas.DataFrame(data = dataset, columns=['Name', 'Number']) 
df 
 
# plot the data 
df['Number'].plot() 

The steps for the script are as follows:

  1. Import the graphics library (and...

Python random numbers in Jupyter

For many analyses, we are interested in calculating repeatable results. However, much of this analysis relies on some random numbers being used. In Python, you can set seed for the random number generator to achieve repeatable results with the random.seed() function.

In this example, we simulate rolling a pair of dice and look at the outcome. We would expect the average total of the two dice to be six, which is the half-way point between the faces.

The script we are using is as follows:

# using pylab statistics and histogram
import pylab
import random

# set random seed so we can reproduce results
random.seed(113)
samples = 1000

# declare our dataset store
dice = []

# generate and save the samples
for i in range(samples):
total = random.randint(1,6) + random.randint(1,6)
dice.append(total)

# compute some statistics on the dice throws
print("Throw...

Summary

In this chapter, we walked through a simple Notebook and the underlying structure. Then, we saw an example of using pandas and looked at a graphics example. Finally, we looked at an example using random numbers in a Python script.

In the next chapter, we will learn about R scripting in a Jupyter Notebook.

Left arrow icon Right arrow icon

Key benefits

  • Learn how to use Jupyter 5.x features such as cell tagging and attractive table styles
  • Leverage big data tools and datasets with different Python packages
  • Explore multiple-user Jupyter Notebook servers

Description

The Jupyter Notebook allows you to create and share documents that contain live code, equations, visualizations, and explanatory text. The Jupyter Notebook system is extensively used in domains such as data cleaning and transformation, numerical simulation, statistical modeling, and machine learning. Learning Jupyter 5 will help you get to grips with interactive computing using real-world examples. The book starts with a detailed overview of the Jupyter Notebook system and its installation in different environments. Next, you will learn to integrate the Jupyter system with different programming languages such as R, Python, Java, JavaScript, and Julia, and explore various versions and packages that are compatible with the Notebook system. Moving ahead, you will master interactive widgets and namespaces and work with Jupyter in a multi-user mode. By the end of this book, you will have used Jupyter with a big dataset and be able to apply all the functionalities you’ve explored throughout the book. You will also have learned all about the Jupyter Notebook and be able to start performing data transformation, numerical simulation, and data visualization.

Who is this book for?

Learning Jupyter 5 is for developers, data scientists, machine learning users, and anyone working on data analysis or data science projects across different teams. Data science professionals will also find this book useful for performing technical and scientific computing collaboratively.

What you will learn

  • Install and run the Jupyter Notebook system on your machine
  • Implement programming languages such as R, Python, Julia, and JavaScript with the Jupyter Notebook
  • Use interactive widgets to manipulate and visualize data in real time
  • Start sharing your Notebook with colleagues
  • Invite your colleagues to work with you on the same Notebook
  • Organize your Notebook using Jupyter namespaces
  • Access big data in Jupyter for dealing with large datasets using Spark

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Aug 30, 2018
Length: 282 pages
Edition : 2nd
Language : English
ISBN-13 : 9781789137446
Category :
Languages :
Concepts :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Aug 30, 2018
Length: 282 pages
Edition : 2nd
Language : English
ISBN-13 : 9781789137446
Category :
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 120.97
Jupyter Cookbook
$43.99
Applied Data Science with Python and Jupyter
$32.99
Learning Jupyter 5
$43.99
Total $ 120.97 Stars icon
Banner background image

Table of Contents

13 Chapters
Introduction to Jupyter Chevron down icon Chevron up icon
Jupyter Python Scripting Chevron down icon Chevron up icon
Jupyter R Scripting Chevron down icon Chevron up icon
Jupyter Julia Scripting Chevron down icon Chevron up icon
Jupyter Java Coding Chevron down icon Chevron up icon
Jupyter JavaScript Coding Chevron down icon Chevron up icon
Jupyter Scala Chevron down icon Chevron up icon
Jupyter and Big Data Chevron down icon Chevron up icon
Interactive Widgets Chevron down icon Chevron up icon
Sharing and Converting Jupyter Notebooks Chevron down icon Chevron up icon
Multiuser Jupyter Notebooks Chevron down icon Chevron up icon
What's Next? Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.5
(2 Ratings)
5 star 0%
4 star 0%
3 star 50%
2 star 50%
1 star 0%
Empty Mailbox Apr 14, 2019
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
The first two chapters explain Jupyter, and introduces Python. The bulk of the book walks the reader through setup, and practical application for various programing languages: R, Julia, Scala, and more. If you are interested in utilizing these languages with Jupyter, or contrasting these languages and your current method of working then this book is for you. Towards the end of the book the author outlines several useful Jupyter topics like interactive user interface widgets. Practical advice on sharing notebooks with others through solutions like JupyterHub, and Docker are explained; as well as there limitations. There's also a good section on exporting your results for communication with others. I look forward to a future book on the new JupyterLabs.
Amazon Verified review Amazon
Brendan O'Sullivan Feb 11, 2021
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
Of the 7 kernels the author offers to install in the separate chapters for Jupyter Lab: Python, R, Java, Javascript, Julia, Spark, Scala, only 2, Python and R, were able to work per the instructions in this book. Very disappointing!!!!The author too often comments and explains: "This example does not work in Windows," or "Major caveat is this does not work on a Windows environment. A Java Notebook will not start on Windows," and "This example does not work in Windows. The Windows install required Microsoft Visual C++ to be installed. I tried several iterations to no avail."With such omissions and admissions, why was this book sent to press???
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.