Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
IPython Notebook Essentials
IPython Notebook Essentials

IPython Notebook Essentials: Compute scientific data and execute code interactively with NumPy and SciPy

eBook
$9.99 $22.99
Paperback
$38.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

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

IPython Notebook Essentials

Chapter 1. A Tour of the IPython Notebook

This chapter gives a brief introduction to the IPython notebook and highlights some of its special features that make it a great tool for scientific and data-oriented computing. IPython notebooks use a standard text format that makes it easy to share results.

After the quick installation instructions, you will learn how to start the notebook and be able to immediately use IPython to perform computations. This simple, initial setup is all that is needed to take advantage of the many notebook features, such as interactively producing high quality graphs, performing advanced technical computations, and handling data with specialized libraries.

All examples are explained in detail in this book and available online. We do not expect the readers to have deep knowledge of Python, but readers unfamiliar with the Python syntax can consult Appendix B, A Brief Review of Python, for an introduction/refresher.

In this chapter, we will cover the following topics:

  • Getting started with Anaconda or Wakari
  • Creating notebooks and then learning about the basics of editing and executing statements
  • An applied example highlighting the notebook features

Getting started with Anaconda or Wakari

There are several approaches to setting up an IPython notebook environment. We suggest you use Anaconda, a free distribution designed for large-scale data processing, predictive analytics, and scientific computing. Alternatively, you can use Wakari, which is a web-based installation of Anaconda. Wakari has several levels of service, but the basic level is free and suitable for experimenting and learning.

Tip

We recommend that you set up both a Wakari account and a local Anaconda installation. Wakari has the functionality of easy sharing and publication. This local installation does not require an Internet connection and may be more responsive. Thus, you get the best of both worlds!

Installing Anaconda

To install Anaconda on your computer, perform the following steps:

  1. Download Anaconda for your platform from https://store.continuum.io/cshop/anaconda/.
  2. After the file is completely downloaded, install Anaconda:
    • Windows users can double-click on the installer and follow the on-screen instruction
    • Mac users can double-click the .pkg file and follow the instructions displayed on screen
    • Linux users can run the following command:
      bash <downloaded file>
      

Note

Anaconda supports several different versions of Python. This book assumes you are using Version 2.7, which is the standard version that comes with Anaconda. The most recent version of Python, Version 3.0, is significantly different and is just starting to gain popularity. Many Python packages are still only fully supported in Version 2.7.

Running the notebook

You are now ready to run the notebook. First, we create a directory named my_notebooks to hold your notebooks and open a terminal window at this directory. Different operating systems perform different steps.

Microsoft Windows users need to perform the following steps:

  1. Open Window Explorer.
  2. Navigate to the location where your notebooks are stored.
  3. Click on the New Folder button.
  4. Rename the folder my_notebooks.
  5. Right-click on the my_notebooks folder and select Open command window here from the context menu.

Mac OS X and other Unix-like systems' users need to perform the following steps:

  1. Open a terminal window.
  2. Run the following commands:
    mkdir my_notebooks
    cd my_notebooks
    
  3. Then, execute the following command on the terminal window:
    ipython notebook
    

After a while, your browser will automatically load the notebook dashboard as shown in the following screenshot. The dashboard is a mini filesystem where you can manage your notebooks. The notebooks listed in the dashboard correspond exactly to the files you have in the directory where the notebook server was launched.

Running the notebook

Tip

Internet Explorer does not fully support all features in the IPython notebook. It is suggested that you use Chrome, Firefox, Safari, Opera, or another standards-conforming browser. If your default browser is one of those, you are ready to go. Alternatively, close the Internet Explorer notebook, open a compatible browser, and enter the notebook address given in the command window from which you started IPython. This will be something like http://127.0.0.1:8888 for the first notebook you open.

Creating a Wakari account

To access Wakari, simply go to https://www.wakari.io and create an account. After logging in, you will be automatically directed to an introduction to using the notebook interface in Wakari. This interface is shown in the following screenshot:

Creating a Wakari account

The interface elements as seen in the preceding screenshot are described as follows:

  • The section marked 1 shows the directory listing of your notebooks and files. On the top of this area, there is a toolbar with buttons to create new files and directories as well as download and upload files.
  • The section marked 2 shows the Welcome to Wakari notebook. This is the initial notebook with information about IPython and Wakari. The notebook interface is discussed in detail in Chapter 2, The Notebook Interface.
  • The section marked 3 shows the Wakari toolbar. This has the New Notebook button and drop-down menus with other tools.

Note

This book concentrates on using IPython through the notebook interface. However, it's worth mentioning the two other ways to run IPython.

The simplest way to run IPython is to issue the ipython command in a terminal window. This starts a command-line session of IPython. As the reader may have guessed, this is the original interface for IPython.

Alternatively, IPython can be started using the ipython qtconsole command. This starts an IPython session attached to a QT window. QT is a popular multiplatform windowing system that is bundled with the Anaconda distribution. These alternatives may be useful in systems that, for some reason, do not support the notebook interface.

Creating your first notebook

We are ready to create our first notebook! Simply click on the New Notebook button to create a new notebook.

  • In a local notebook installation, the New Notebook button appears in the upper-left corner of the dashboard.
  • In Wakari, the New Notebook button is at the top of the dashboard, in a distinct color. Do not use the Add File button.

Notice that the Wakari dashboard contains a directory list on the left. You can use this to organize your notebooks in any convenient way you choose. Wakari actually provides access to a fully working Linux shell.

We are now ready to start computing. The notebook interface is displayed in the following screenshot:

Creating your first notebook

By default, new notebooks are named UntitledX, where X is a number. To change it, just click on the current title and edit the dialog that pops up.

At the top of the notebook, you will see an empty box with the In [ ]: text on the left-hand side. This box is called a code cell and it is where the IPython shell commands are entered. Usually, the first command we issue in a new notebook is %pylab inline. Go ahead and type this line in the code cell and then press Shift + Enter (this is the most usual way to execute commands. Simply pressing Enter will create a new line in the current cell.) Once executed, this command will issue a message as follows:

Populating the interactive namespace from numpy and matplotlib

This command makes several computational tools easily available and is the recommended way to use the IPython notebook for interactive computations. The inline directive tells IPython that we want graphics embedded in the notebook and not rendered with an external program.

Commands that start with % and %% are called magic commands and are used to set up configuration options and special features. The %pylab magic command imports a large collection of names into the IPython namespace. This command is usually frowned upon for causing namespace pollution. The recommended way to use libraries in scripts is to use the following command:

import numpy as np

Then, for example, to access the arange() function in the NumPy package, one uses np.arange(). The problem with this approach is that it becomes cumbersome to use common mathematical functions, such as sin(), cos(), and so on. These would have to be entered as np.sin(), np.cos(), and so on, which makes the notebook much less readable.

In this book, we adopt the following middle-of-the road convention: when doing interactive computations, we will use the %pylab directive to make it easier to type formulae. However, when using other libraries or writing scripts, we will use the recommended best practices to import libraries.

Example – the coffee cooling problem

Suppose you get a cup of coffee at a coffee shop. Should you mix the cream into the coffee at the shop or wait until you reach your office? The goal, we assume, is to have the coffee as hot as possible. So, the main question is how the coffee is going to cool as you walk back to the office.

The difference between the two strategies of mixing cream is:

  • If you pour the cream at the shop, there is a sudden drop of temperature before the coffee starts to cool down as you walk back to the office
  • If you pour the cream after getting back to the office, the sudden drop occurs after the cooling period during the walk

We need a model for the cooling process. The simplest such model is Newton's cooling law, which states that the rate of cooling is proportional to the temperature difference between the coffee in the cup and the ambient temperature. This reflects the intuitive notion that, for example, if the outside temperature is 40°F, the coffee cools faster than if it is 50°F. This assumption leads to a well-known formula for the way the temperature changes:

Example – the coffee cooling problem

The constant r is a number between 0 and 1, representing the heat exchange between the coffee cup and the outside environment. This constant depends on several factors, and may be hard to estimate without experimentation. We just chose it somewhat arbitrarily in this first example.

We will start by setting variables to represent the outside temperature and the rate of cooling and defining a function that computes the temperatures as the liquid cools. Then, type the lines of code representing the cooling law in a single code cell. Press Enter or click on Return to add new lines to the cell.

As discussed, we will first define the variables to hold the outside temperature and the rate of cooling:

temp_out = 70.0
r = 0.9

After entering the preceding code on the cell, press Shift + Enter to execute the cell. Notice that after the cell is executed, a new cell is created.

Note

Notice that we entered the value of temp_out as 70.0 even though the value is an integer in this case. This is not strictly necessary in this case, but it is considered good practice. Some code may behave differently, depending on whether it operates on integer or floating-point variables. For example, evaluating 20/8 in Python Version 2.7 results in 2, which is the integer quotient of 20 divided by 8. On the other hand, 20.0/8.0 evaluates to the floating-point value 2.5. By forcing the variable temp_out to be a floating-point value, we prevent this somewhat unexpected kind of behavior.

A second reason is to simply improve code clarity and readability. A reader of the notebook on seeing the value 70.0 will easily understand that the variable temp_out represents a real number. So, it becomes clear that a value of 70.8, for example, would also be acceptable for the outside temperature.

Next, we define the function representing the cooling law:

def cooling_law(temp_start, walk_time):
    return temp_out + (temp_start - temp_out) * r ** walk_time 

Note

Please be careful with the way the lines are indented, since indentation is used by Python to define code blocks. Again, press Shift + Enter to execute the cell.

The cooling_law()function accepts the starting temperature and walking time as the input and returns the final temperature of the coffee. Notice that we are only defining the function, so no output is produced. In our examples, we will always choose meaningful names for variables. To be consistent, we use the conventions in the Google style of coding for Python as shown in http://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Python_Language_Rules.

Note

Notice that the exponentiation (power) operator in Python is ** and not ^ as in other mathematical software. If you get the following error when trying to compute a power, it is likely that you meant to use the ** operator:

TypeError: unsupported operand type(s) for ^: 'float' and 'float'

We can now compute the effect of cooling given any starting temperature and walking time. For example, to compute the temperature of the coffee after 10 minutes, assuming the initial temperature to be 185°F, run the following code in a cell:

cooling_law(185.0, 10.0)

The corresponding output is:

110.0980206115

What if we want to know what the final temperature for several walking times is? For example, suppose that we want to compute the final temperature every 5 minutes up to 20 minutes. This is where NumPy makes things easy:

times = arange(0.,21.,5.)
temperatures = cooling_law(185., times)
temperatures

We start by defining times to be a NumPy array, using the arange() function. This function takes three arguments: the starting value of the range, the ending value of the range, and the increment.

Note

You may be wondering why the ending value of the range is 21 and not 20. It's a common convention in Computer Science, followed by Python. When a range is specified, the right endpoint never belongs to the range. So, if we had specified 20 as the right endpoint, the range would only contain the values 0, 5, 10, and 15.

After defining the times array, we can simply call the cooling_law() function with times as the second argument. This computes the temperatures at the given times.

Note

You may have noticed that there is something strange going on here. The first time the cooling_law() function was called, the second argument was a floating-point number. The second time, it was a NumPy array. This is possible thanks to Python's dynamic typing and polymorphism. NumPy redefines the arithmetic operators to work with arrays in a smart way. So, we do not need to define a new function especially for this case.

Once we have the temperatures, we can display them in a graph. To display the graph, execute the following command line in a cell:

plot(times, temperatures, 'o')

The preceding command line produces the following plot:

Example – the coffee cooling problem

The plot() function is a part of the matplotlib package, which will be studied in detail in Chapter 3, Graphics with matplotlib. In this example, the first two arguments to plot() are NumPy arrays that specify the data for the horizontal and vertical axes, respectively. The third argument specifies the plot symbol to be a filled circle.

We are now ready to tackle the original problem: should we mix the cream in at the coffee shop or wait until we get back to the office? When we mix the cream, there is a sudden drop in temperature. The temperature of the mixture is the average of the temperature of the two liquids, weighted by volume. The following code defines a function to compute the resulting temperature in a mix:

def temp_mixture(t1, v1, t2, v2):
    return (t1 * v1 + t2 * v2) / (v1 + v2)

The arguments in the function are the temperature and volume of each liquid. Using this function, we can now compute the temperature evolution when the cream is added at the coffee shop:

temp_coffee = 185.
temp_cream = 40.
vol_coffee = 8.
vol_cream = 1.
initial_temp_mix_at_shop = temp_mixture(temp_coffee, vol_coffee, temp_cream, vol_cream)
temperatures_mix_at_shop = cooling_law(initial_temp_mix_at_shop, times)
temperatures_mix_at_shop

Tip

Notice that we repeat the variable temperatures_mix_at_shop at the end of the cell. This is not a typo. The IPython notebook, by default, assumes that the output of a cell is the last expression computed in the cell. It is a common idiom to list the variables one wants to have displayed, at the end of the cell. We will later see how to display fancier, nicely formatted output.

As usual, type all the commands in a single code cell and then press Shift + Enter to run the whole cell. We first set the initial temperatures and volumes for the coffee and the cream. Then, we call the temp_mixture() function to calculate the initial temperature of the mixture. Finally, we use the cooling_law() function to compute the temperatures for different walking times, storing the result in the temperatures_mix_at_shop variable. The preceding command lines produce the following output:

array([ 168.88888889,  128.3929    ,  104.48042352,   90.36034528,
         82.02258029])

Remember that the times array specifies times from 0 to 20 with intervals of 5 minutes. So, the preceding output gives the temperatures at these times, assuming that the cream was mixed in the shop.

To compute the temperatures when considering that the cream is mixed after walking back to our office, execute the following commands in the cell:

temperatures_unmixed_coffee = cooling_law(temp_coffee, times)
temperatures_mix_at_office = temp_mixture(temperatures_unmixed_coffee, vol_coffee, temp_cream, vol_cream)
temperatures_mix_at_office

We again use the cooling_law() function, but using the initial coffee temperature temp_coffee (without mixing the cream) as the first input variable. We store the results in the temperatures_unmixed_coffee variable.

To compute the effect of mixing the cream in after walking, we call the temp_mixture() function. Notice that the main difference in the two computations is the order in which the functions cooling_law() and temp_mixture() are called. The preceding command lines produce the following output:

array([ 168.88888889,  127.02786667,  102.30935165,   87.71331573,
         79.09450247])

Let's now plot the two temperature arrays. Execute the following command lines in a single cell:

plot(times, temperatures_mix_at_shop, 'o')
plot(times, temperatures_mix_at_office, 'D', color='r')

The first plot() function call is the same as before. The second is similar, but we want the plotting symbol to be a filled diamond, indicated by the argument 'D'. The color='r' option makes the markings red. This produces the following plot:

Example – the coffee cooling problem

Notice that, by default, all graphs created in a single code cell will be drawn on the same set of axes. As a conclusion, we can see that, for the data parameters used in this example, mixing the cream at the coffee shop is always better no matter what the walking time is. The reader should feel free to change the parameters and observe what happens in different situations.

Scientific plots should make clear what is being represented, the variables being plotted, as well as the units being used. This can be nicely handled by adding annotations to the plot. It is fairly easy to add annotations in matplotlib, as shown in the following code:

plot(times, temperatures_mix_at_shop, 'o')
plot(times, temperatures_mix_at_office, 'D', color='r')
title('Coffee temperatures for different walking times')
xlabel('Waking time (min)')
ylabel('Temperature (F)')
legend(['Mix at shop', 'Mix at office']) 

After plotting the arrays again, we call the appropriate functions to add the title (title()), horizontal axis label (xlabel()), vertical axis label (ylabel()), and legend (legend()). The arguments to all this functions are strings or a list of strings as in the case of legend(). The following graph is what we get as an output for the preceding command lines:

Example – the coffee cooling problem

There is something unsatisfactory about the way we conducted this analysis; our office, supposedly, is at a fixed distance from the coffee shop. The main factor in the situation is the outside temperature. Should we use different strategies during summer and winter? In order to investigate this, we start by defining a function that accepts as input both the cream temperature and outside temperature. The return value of the function is the difference of final temperatures when we get back to the office.

The function is defined as follows:

temp_coffee = 185.
vol_coffee = 8.
vol_cream = 1.
walk_time = 10.0
r = 0.9
def temperature_difference(temp_cream, temp_out):
    temp_start = temp_mixture(temp_coffee,vol_coffee,temp_cream,vol_cream)
    temp_mix_at_shop = temp_out + (temp_start - temp_out) * r ** walk_time
    temp_start = temp_coffee
    temp_unmixed =  temp_out + (temp_start - temp_out) * r ** walk_time
    temp_mix_at_office = temp_mixture(temp_unmixed, vol_coffee, temp_cream, vol_cream)
    return temp_mix_at_shop - temp_mix_at_office

In the preceding function, we first set the values of the variables that will be considered constant in the analysis, that is, the temperature of the coffee, the volumes of coffee and cream, the walking time, and the rate of cooling. Then, we defined the temperature_difference function using the same formulas we discussed previously. We can now use this function to compute a matrix with the temperature differences for several different values of the cream temperature and outside temperature:

cream_temperatures = arange(40.,51.,1.)
outside_temperatures = arange(35.,60.,1.)
cream_values, outside_values = meshgrid(cream_temperatures, outside_temperatures)
temperature_differences = temperature_difference(cream_values, outside_values)

The first two lines in the cell use the arange() function to define arrays that contain equally spaced values for the cream temperatures and outside temperatures. We then call the convenience function, meshgrid(). This function returns two arrays that are convenient to calculate data for three-dimensional graphs and are stored in the variables cream_values and outside_values. Finally, we call the temperature_difference() function, and store the return value in the temperature_differences array. This will be a two-dimensional array (that is, a matrix).

We are now ready to create a three dimensional plot of the temperature differences:

from mpl_toolkits.mplot3d import Axes3D
fig = figure()
fig.set_size_inches(7,5)
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(cream_values, outside_values, temperature_differences, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0)
xlabel('Cream temperature')
ylabel('Outside temperature')
title('Temperature difference') 

In the preceding code segment, we started by importing the Axes3D class using the following line:

from mpl_toolkits.mplot3d import Axes3D

This class, located in the mpl_toolkits.mplot3d module, is not automatically loaded. So, it must be explicitly imported.

Then we create an object fig of the class figure, set its size, and generate an object ax that is an object of the class Axes3D. Finally, we call the ax.plot_surface() method to generate the plot. The last three command lines set the axis labels and the title.

Note

In this explanation, we used some terms that are common in object-oriented programming. A Python object is simply a data structure that can be handled in some specialized way. Every object is an instance of a class that defines the object's data. The class also defines methods, which are functions specialized to work with objects belonging to the class.

The output of the preceding command lines will produce the following graph:

Example – the coffee cooling problem

Notice the cmap=cm.coolwarm argument in the call to ax.plot_surface(). This sets the color map of the plot to cm.coolwarm. This color map conveniently uses a blue-red gradient for the function values. As a result, negative temperature differences are shown in blue and positive temperatures in red. Notice that there seems to be a straight line that defines where the temperature difference transitions from negative to positive. This actually corresponds to values where the outside temperature and the cream temperature are equal. It turns out that if the cream temperature is lower than the outside temperature, we should mix the cream into the coffee at the coffee shop. Otherwise, the cream should be poured in the office.

Exercises

The following are some practice questions that will help you to understand and apply the concepts learned in this chapter:

  • In our example, we discussed how to determine the cooling rate r. Modify the example to plot the temperature evolution for several values of r, keeping all other variables fixed.
  • Search the matplotlib documentation at http://matplotlib.org to figure out how to generate a contour plot of the temperature differences.

    Our analysis ignores the fact that the cream will also change temperature as we walk. Change the notebook so that this factor is taken into account

Summary

In this chapter, we set up an IPython environment with Anaconda, accessed the IPython notebook online through Wakari, created a notebook, and learned the basics of editing and executing commands, and lastly, we went through an extensively applied example featuring the basic notebook capabilities.

In the next chapter, we will delve more deeply in the facilities provided by the notebook interface—including notebook navigation and editing facilities, interfacing with the operating system, loading and saving data, and running scripts.

Left arrow icon Right arrow icon

Description

If you are a professional, student, or educator who wants to learn to use IPython Notebook as a tool for technical and scientific computing, visualization, and data analysis, this is the book for you. This book will prove valuable for anyone that needs to do computations in an agile environment.
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 21, 2014
Length: 190 pages
Edition : 1st
Language : English
ISBN-13 : 9781783988341
Category :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Publication date : Nov 21, 2014
Length: 190 pages
Edition : 1st
Language : English
ISBN-13 : 9781783988341
Category :
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 $ 148.97
IPython Interactive Computing and Visualization Cookbook
$54.99
IPython Notebook Essentials
$38.99
Python Data Analysis
$54.99
Total $ 148.97 Stars icon
Banner background image

Table of Contents

9 Chapters
1. A Tour of the IPython Notebook Chevron down icon Chevron up icon
2. The Notebook Interface Chevron down icon Chevron up icon
3. Graphics with matplotlib Chevron down icon Chevron up icon
4. Handling Data with pandas Chevron down icon Chevron up icon
5. Advanced Computing with SciPy, Numba, and NumbaPro Chevron down icon Chevron up icon
A. IPython Notebook Reference Card Chevron down icon Chevron up icon
B. A Brief Review of Python Chevron down icon Chevron up icon
C. NumPy Arrays Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.7
(3 Ratings)
5 star 0%
4 star 66.7%
3 star 33.3%
2 star 0%
1 star 0%
Al Sweigart Dec 17, 2014
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
IPython Notebook Essentials is a solid introduction to IPython Notebook that I would recommend for scientists or others who need to learn to code for their job. IPython Notebook itself is a sort of hybrid of Excel, MATLAB, and Python IDE, and this book touches on a wide range of related topics.Don't mistake this book for simply covering just IPython on Notebook. The first two chapters teach you the ropes of the software, and the later chapters cover generating graphs with matplotlib, processing & analyzing data with Pandas (a Python software library), and doing more advanced mathematics with the SciPy, Numba, and NumbaPro libraries.IPython Notebook Essentials is a light introduction (IPython itself is fairly easy to pick up), but the strength of the book is that it brings the reader into contact with several related libraries. The examples in the book might not be exactly relevant to your field, but the skills they demonstrate will be. Following along with them on your own computer will let you get the most from this book.The main criticism I would have of the book is that it is wide but not deep. But if you understand this going into the book, you won't be disappointed.If you want to learn programming in general, this is not the book for you. If you don't mind haphazardly sorting through free tutorials on the web, then you can learn the same concepts that are presented in this book. But if you are in the particular niche of scientist or administrator who needs to do number crunching, has a small amount of previous Python programming experience, and want a light introduction to the Python ecosystem of data analysis tools, IPython Notebook Essentials is a good start.Disclosure: I received a free ebook review copy of IPython Notebook Essentials from Packt Publishing for the purposes of writing this review. I do not have any business ties to Packt Publishing.
Amazon Verified review Amazon
Mike Driscoll Dec 04, 2014
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
The book starts out by giving the reader a tour of the IPython Notebook in chapter one. The author recommends that you use the Anaconda distribution of Python and that you sign up for Wakari to make sharing Notebooks easier. Then you learn how to run a notebook and the author goes into an example using a coffee cooling algorithm. That may sound a little strange, but it was actually pretty interesting to learn about how to calculate how much coffee cools over time. I also thought it was a good way to demonstrate the Notebook’s capabilities. The chapter ends with a few brief exercises.In chapter two, we learn more about the Notebook’s interface. Here we learn how to edit and navigate the Notebook and IPython magics. You will also learn how to run script and load and save data. The chapter ends with a few examples showing how to embed images, Youtube videos and HTML in your Notebook. I liked this chapter quite a bit.For chapter three, we change gears dramatically. From this point on until we reach the appendices, the book is basically for scientists. This chapter is about creating plots and animations with Matplotlib inside the Notebook. The Notebook itself is rarely discussed.Chapter four is all about the pandas project, which is a powerful library for data handling and analytics. This is outside my field, so I cannot comment on its accuracy, let alone understand everything the author writes about in this chapter. Suffice it to say, I only skimmed chapter four.Chapter five is about SciPy, Numba and NumbaPro. Once again, the focus is on scientific computations (SciPy) and how to accelerate those computations (Numba/NumbaPro). I skipped this chapter too.The Appendices cover the following: An IPython Notebook Reference Card, A brief overview of the Python language, and NumPy Arrays.Going into this book, I assumed that it would be a guide to the IPython Notebook. The title certainly gives one that impression. However, the majority of the book is not about the IPython Notebook at all and instead focuses on scientific computing with Python. There are many other books that cover that topic and perhaps the IPython Notebook is used mostly by scientists. The preface states that the book is supposed to be learning about the Notebook too along with some of these other libraries. I just felt that the scientific libraries got the majority of the prose and the Notebook got short shrift.If you are looking for a guide to the IPython Notebook, I’m not sure I can recommend this book for you. It only has 2 chapters that focus exclusively on that topic plus a reference card in the appendix. On the other hand, if you are looking for a very brief overview of some of the scientific libraries you can use in Python plus learn how to use the IPython Notebook in general, then this might be the book for you.
Amazon Verified review Amazon
Matteo Jan 18, 2015
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
The book is supposed to make you learn ipython by throwing you into a field course of examples but the explanations are not on the same level in all the examples, some are well documented and easy to read others are a bit too cryptic for a newcomer. Try using this book along with some other books if you are not well versed in the language but keep in mind that the code samples are based on python 2.7, if you want to learn or have a set of language samples/examples using the 3.x branch you should use Cyrille Rossant's books from the same publisher.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela