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 NumPy Array
Learning NumPy Array

Learning NumPy Array: Supercharge your scientific Python computations by understanding how to use the NumPy library effectively

eBook
€8.99 €18.99
Paperback
€22.99
Subscription
Free Trial
Renews at €18.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

Learning NumPy Array

Chapter 2. NumPy Basics

After installing NumPy and getting some code to work, it's time to cover NumPy basics. This chapter introduces you to the fundamentals of NumPy and arrays. At the end of this chapter you will have a basic understanding of NumPy arrays and their associated functions.

The topics that we shall cover in this chapter are as follows:

  • Data types

  • Array types

  • Type conversions

  • Creating arrays

  • Indexing

  • Fancy indexing

  • Slicing

  • Manipulating shapes

The NumPy array object


NumPy has a multidimensional array object called ndarray. It consists of two parts as follows:

  • The actual data

  • Some metadata describing the data

The majority of array operations leave the raw data untouched. The only aspect that changes is the metadata.

We have already learned in the previous chapter how to create an array using the arange() function. Actually, we created a one-dimensional array that contained a set of numbers. The ndarray object can have more than one dimension.

The advantages of using NumPy arrays

A NumPy array is a general homogeneous array—the items in an array have to be of the same type (there is a special array type that is heterogeneous). The advantage is that if we know that the items in an array are of the same type, it is easy to determine the storage size required for the array. NumPy arrays can perform vectorized operations working on a whole array. Contrast this to Python lists, where normally you have to loop through the list and perform operations...

Creating a multidimensional array


Now that we know how to create a vector, we are ready to create a multidimensional NumPy array. After we create the matrix, we will again want to display its shape (see the arrayattributes.py file in the Chapter02 folder of this book's code bundle), as shown in the following code snippets:

  • To create a multidimensional array, see the following code:

    In: m = array([arange(2), arange(2)])
    In: m
    Out:
    array([[0, 1],[0, 1]])
  • To display the array shape, see the following lines of code:

    In: m.shape
    Out: (2, 2)

We created a 2 x 2 array with the arange() function. Without any warning, the array() function appeared on the stage.

The array() function creates an array from an object that you give to it. The object needs to be array-like, for instance, a Python list. In the preceding example, we passed in a list of arrays. The object is the only required argument of the array() function. NumPy functions tend to have a lot of optional arguments with predefined defaults.

Selecting array elements


From time to time, we will want to select a particular element of an array. We will take a look at how to do this, but first, let's create a 2 x 2 matrix again (see the elementselection.py file in the Chapter02 folder of this book's code bundle):

In: a = array([[1,2],[3,4]])
In: a
Out:
array([[1, 2],       [3, 4]])

The matrix was created this time by passing a list of lists to the array() function. We will now select each item of the matrix one at a time, as shown in the following code snippet. Remember, the indices are numbered starting from 0.

In: a[0,0]
Out: 1
In: a[0,1]
Out: 2
In: a[1,0]
Out: 3
In: a[1,1]
Out: 4

As you can see, selecting elements of the array is pretty simple. For the array a, we just use the notation a[m,n], where m and n are the indices of the item in the array.

NumPy numerical types


Python has an integer type, a float type, and a complex type; however, this is not enough for scientific computing. In practice, we need even more data types with varying precision, and therefore, different memory size of the type. For this reason, NumPy has a lot more data types. The majority of NumPy numerical types end with a number. This number indicates the number of bits associated with the type. The following table (adapted from the NumPy user guide) gives an overview of NumPy numerical types:

Type

Description

bool

This stores boolean (True or False) as a bit

inti

This is a platform integer (normally either int32 or int64)

int8

This is an integer ranging from-128 to 127

int16

This is an integer ranging from -32768 to 32767

int32

This is an integer ranging from -2 ** 31 to 2 ** 31 -1

int64

This is an integer ranging from -2 ** 63 to 2 ** 63 -1

uint8

This is an unsigned integer ranging from 0 to 255

uint16

This is an unsigned integer...

Creating a record data type


A record data type is a heterogeneous data type—think of it as representing a row in a spreadsheet or a database. To give an example of a record data type, we will create a record for a shop inventory. This record contains the name of an item represented by a 40-character string, the number of items in the store represented by a 32-bit integer, and finally, the price of the item represented by a 32-bit float. The following steps show how to create a record data type (see the record.py file in the Chapter02 folder of this book's code bundle):

  1. To create a record, check the following code snippet:

    In: t = dtype([('name', str_, 40), ('numitems', int32), ('price', float32)])
    In: t
    Out: dtype([('name', '|S40'), ('numitems', '<i4'), ('price', '<f4')])
  2. To view the type of the field, check the following code snippet:

    In: t['name']
    Out: dtype('|S40')

If you don't give the array() function a data type, it will assume that it is dealing with floating point numbers. To create...

One-dimensional slicing and indexing


Slicing of one-dimensional NumPy arrays works just like slicing of Python lists. We can select a piece of an array from the index 3 to 7 that extracts the elements 3 through 6 (see the slicing1d.py file in the Chapter02 folder of this book's code bundle), as shown in the following code snippet:

In: a = arange(9)
In: a[3:7]
Out: array([3, 4, 5, 6])

We can select elements from the index 0 to 7 with a step of two, as shown in the following lines of code:

In: a[:7:2]
Out: array([0, 2, 4, 6])

Just as in Python, we can use negative indices and reverse the array, as shown in the following lines of code:

In: a[::-1]
Out: array([8, 7, 6, 5, 4, 3, 2, 1, 0])

Manipulating array shapes


Another recurring task is flattening of arrays. Flattening in this context means transforming a multidimensional array into a one-dimensional array. In this example, we will demonstrate a number of ways to manipulate array shapes starting with flattening:

  • ravel(): We can accomplish flattening with the ravel() function (see the shapemanipulation.py file in the Chapter02 folder of this book's code bundle), as shown in the following code:

    In: b
    Out:
    array([[[ 0,  1,  2,  3],[ 4,  5,  6,  7],[ 8,  9, 10, 11]],[[12, 13, 14, 15],[16, 17, 18, 19],[20, 21, 22, 23]]])
    In: b.ravel()
    Out:
    array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23])
  • flatten(): The appropriately-named function, flatten(), does the same as ravel(), but flatten() always allocates new memory, whereas ravel() might return a view of an array. This means that we can directly manipulate the array as follows:

    In: b.flatten()
    Out:
    array([ 0,  1,  2,  3,  4,  5...

Creating views and copies


In the example about the ravel() function, views were mentioned. Views should not be confused with the concept of database views. Views in the NumPy world are not read-only, and you don't have the possibility to protect the underlying data. It is important to know when we are dealing with a shared array view and when we have a copy of array data. A slice, for instance, will create a view. This means that if you assign a slice to a variable and then change the underlying array, the value of this variable will change. We will create an array from the famous Lena image, copy the array, create a view, and at the end, modify the view. The Lena image array comes from a SciPy function.

  1. To create a copy of the Lena array, the following line of code is used:

    acopy = lena.copy()
  2. Now, to create a view of the array, use the following line of code:

    aview = lena.view()
  3. Set all the values of the view to 0 with a flat iterator, as follows:

    aview.flat = 0

The end result is that only one...

Fancy indexing


Fancy indexing is indexing that does not involve integers or slices, which is normal indexing. In this section, we will apply fancy indexing to set the diagonal values of the Lena image to 0. This will draw black lines along the diagonals, crossing it through, not because there is something wrong with the image, but just as an exercise. Perform the following steps for fancy indexing:

  1. Set the values of the first diagonal to 0. To set the diagonal values to 0, we need to define two different ranges for the x and y values as follows:

    lena[range(xmax), range(ymax)] = 0
  2. Now, set the values of the other diagonal to 0. To set the values of the other diagonal, we require a different set of ranges, but the principles stay the same, as follows:

    lena[range(xmax-1,-1,-1), range(ymax)] = 0

At the end we get the following image with the diagonals crossed out:

The following code for this section is without comments. The complete code for this is in the fancy.py file in the Chapter02 folder of...

Indexing with a list of locations


Let's use the ix_() function to shuffle the Lena image. This function creates a mesh from multiple sequences. As arguments, we give one-dimensional sequences, and the function returns a tuple of NumPy arrays. For example, check the following code snippet:

In : ix_([0,1], [2,3])
Out:
(array([[0], [1]]), array([[2, 3]]))

To index the array with a list of locations, perform the following steps:

  1. Shuffle the array indices. Create a random indices array with the shuffle() function of the numpy.random module, as shown in the following lines of code. The function changes the array inplace by the way.

    def shuffle_indices(size):
       arr = np.arange(size)
       np.random.shuffle(arr)
    
       return arr
  2. Now plot the shuffled indices as follows:

    plt.imshow(lena[np.ix_(xindices, yindices)])

What we get is a completely scrambled Lena, as shown in the following image:

The following code for this section is without comments. The complete code for this can be found in the ix.py file in the...

Indexing arrays with Booleans


Boolean indexing is indexing based on a Boolean array and falls in the category of fancy indexing. Since Boolean indexing is a form of fancy indexing, the way it works is basically the same. This means that indexing happens with the help of a special iterator object. Perform the following steps to index an array:

  1. First, we create an image with dots on the diagonal. This is in some way similar to the Fancy indexing section. This time we select modulo four points on the diagonal of the image, as shown in the following code snippet:

    def get_indices(size):
       arr = np.arange(size)
       return arr % 4 == 0
  2. Then we just apply this selection and plot the points, as shown in the following code snippet:

    lena1 = lena.copy() 
    xindices = get_indices(lena.shape[0])
    yindices = get_indices(lena.shape[1])
    lena1[xindices, yindices] = 0
    plt.subplot(211)
    plt.imshow(lena1)
  3. Select array values between a quarter and three-quarters of the maximum value, and set them to 0, as shown in the...

Stride tricks for Sudoku


We can do even more fancy things with NumPy. The ndarray class has a field, strides, which is a tuple indicating the number of bytes to step in each dimension when going through an array. Sudoku is a popular puzzle originally from Japan; although it was known in a similar form before in other countries. If you don't know about Sudoku, it's maybe better that way because it is highly addictive. Let's apply some stride tricks to the problem of splitting a Sudoku puzzle to the 3 x 3 squares it is composed of:

  1. First define the Sudoku puzzle array, as shown in the following code snippet. This one is filled with the contents of the actual solved Sudoku puzzle (part of the array is omitted for brevity).

    sudoku = np.array([[2, 8, 7, 1, 6, 5, 9, 4, 3],[9, 5, 4, 7, 3, 2, 1, 6, 8],…[7, 3, 6, 2, 8, 4, 5, 1, 9]])
  2. Now calculate the strides. The itemsize field of ndarray gives us the number of bytes in an array. itemsize calculates the strides as follows:

    strides = sudoku.itemsize ...

Broadcasting arrays


In a nutshell, NumPy tries to perform an operation even though the operands do not have the same shape. In this section, we will multiply an array and a scalar. The scalar is extended to the shape of an array operand, and then the multiplication is performed. We will download an audio file and make a new version that is quieter:

  1. First, read the WAV file. We will use standard Python code to download an audio file of Austin Powers saying "Smashing, baby". SciPy has a wavfile module that allows you to load sound data or generate WAV files. If SciPy is installed, then we should already have this module. The read() function returns a data array and sample rate. In this example, we only care about the data.

    sample_rate, data = scipy.io.wavfile.read(WAV_FILE)
  2. Plot the original WAV data with Matplotlib. Give the subplot the title, Original, as shown in the following lines of code:

    plt.subplot(2, 1, 1)
    plt.title("Original")
    plt.plot(data)
  3. Now create a new array. We will use NumPy to...

Summary


We learned a lot in this chapter about the NumPy fundamentals: data types and arrays. Arrays have several attributes describing them. We learned that one of these attributes is the data type which, in NumPy, is represented by a full-fledged object.

NumPy arrays can be sliced and indexed in an efficient manner, just as in the case of Python lists. NumPy arrays have the added ability of working with multiple dimensions.

The shape of an array can be manipulated in many ways, such as stacking, resizing, reshaping, and splitting. A great number of convenience functions for shape manipulation were demonstrated in this chapter.

Having learned about the basics, it's time to move on to data analysis with commonly used functions in Chapter 3, Basic Data Analysis with NumPy. This includes the usage of basic statistical and mathematical functions.

Left arrow icon Right arrow icon

What you will learn

  • Install NumPy and discover its arrays and features
  • Perform data analysis and complex array operations with NumPy
  • Analyze time series and perform signal processing
  • Understand NumPy modules and explore the scientific Python ecosystem
  • Improve the performance of calculations with clean and efficient NumPy code
  • Analyze large data sets using statistical functions and execute complex linear algebra and mathematical computations
Estimated delivery fee Deliver to Italy

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jun 13, 2014
Length: 164 pages
Edition :
Language : English
ISBN-13 : 9781783983902
Category :
Languages :
Concepts :
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 Italy

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Publication date : Jun 13, 2014
Length: 164 pages
Edition :
Language : English
ISBN-13 : 9781783983902
Category :
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.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
€189.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
€264.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 98.97
NumPy Cookbook
€37.99
Learning NumPy Array
€22.99
NumPy Beginner's Guide
€37.99
Total 98.97 Stars icon
Banner background image

Table of Contents

7 Chapters
Getting Started with NumPy Chevron down icon Chevron up icon
NumPy Basics Chevron down icon Chevron up icon
Basic Data Analysis with NumPy Chevron down icon Chevron up icon
Simple Predictive Analytics with NumPy Chevron down icon Chevron up icon
Signal Processing Techniques Chevron down icon Chevron up icon
Profiling, Debugging, and Testing Chevron down icon Chevron up icon
The Scientific Python Ecosystem Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(9 Ratings)
5 star 55.6%
4 star 22.2%
3 star 0%
2 star 11.1%
1 star 11.1%
Filter icon Filter
Top Reviews

Filter reviews by




Edward Grefenstette Aug 07, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The following review was produced after being sent a free copy of the book by Packt Publishing. I have endeavoured to be objective and state my view of the book, unaltered by this."Learning NumPy Array" by Ivan Idris is an excellent book which covers a range of use cases for the Python NumPy library across different aspects of scientific computing. It gives a short introduction to NumPy classes and core functions, discusses data analysis with NumPy data structures, and then using the pandas library (built on top of NumPy, amongst other libraries), provides a succinct overview of signal processing techniques with NumPy, followed by a short tutorial of profiling and debugging NumPy code with iPython, UnitTest, and Nose. The book ends with a helpful chapter on other tools scientific computing programmers may wish to consider alongside NumPy, most importantly cython and sklearn.While the book is entitled "Learning NumPy Array", it is not exactly aimed at a beginner audience. The reader is assumed to have a decent knowledge of linear algebra, statistics, and some cursory experience with similar statistics or matrix libraries/languages such as Matlab or R. While it does introduce NumPy basics, the reader should expect to have access to the NumPy documentation while reading the book to get the most out of it. Chapters 3 through 5 are quite dense, and readers without experience with the relevant areas (statistical analysis for chapters 3-4 and signal processing for chapter 5) will need to spend time and perhaps read third-party sources to get the most out of the material. All this is to say, this is a fairly technical book, but the examples are many, are well spelled-out, and coherently explained. Readers with a bit of experience in the domains it covers, or readers who are willing to put in the extra effort to read around the topics, will get a lot out of this book, and be able to implement solutions to similar problems quickly.In addition to the core material covered in chapters 3-5, I particularly enjoyed the fairly clear tutorials for profiling, debugging and testing in chapter six. Some of this material could easily have been excluded from the book in favour of expanding the explanations and giving some background in chapters 3-5, but I found the explanations to be well written and helpful, so the inclusion in this book is appreciated.Furthermore, the final chapter is a nice starting point for newcomers to the python scientific computing world, as it presents some helpful pointers (and use examples) to other resources available. Even as a researcher who has used these tools before once or twice, at least, this chapter was a good read and reminded me of how easily these libraries play with each other.Overall, this is a good read. It will take some small effort for most readers to get through the more technical sections of this book, but there is a lot to get out of reading it. While the same material can be found in several tutorials scattered around the web, it is good to see that someone took the effort to distil all the material into one volume, provide excellent example code, and enough explanation to feed intuitions as to how to best apply the knowledge presented in it.
Amazon Verified review Amazon
alan1955 Sep 17, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is an excellent book for learning NumPy. It is for someone who has experience with python and numerical coding. What I liked was chapter two where the book covers the basics of NumPy to get you quickly up and running. All in one chapter. So if you are already trying to do some basic things with NumPy, it will save you a lot of time. The rest of the book is filled with examples. The examples illustrate things you can do with NumPy, and are arranged topically. The topics cover basic data analysis, predictive analysis, smoothing, moving averages, and sifting. The other plus is that it introduces Scipy, the scientific python programming package. If you are not familiar with it, you will get to see what it can do in a few of the examples. It is also a short book. Being short it assumes you have a working knowledge of Python and some numerical experience. Too many computer books are so long, you can never get through them. Because of this you can quickly get up to speed. Also the code for examples can be downloaded, which is very helpful.
Amazon Verified review Amazon
Roberto Avilés Jul 30, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is a 7 chapters, +140 page hands-on introduction to the power of Python’s Library, NumPy.In Chapter 1, we learn to install Python, SciPy, Matplotlib, IPython and NumPy on Windows, Linux and Macintosh machines and start writing NumPy code.Chapter 2 reviews the basics on NumPy: Data Types, Array Types, Type Conversions, Creating, Indexing, Slicing and Manipulating array Shapes. Advantages of NumPy arrays: we know items in the array are of the same type (example, dtype!) plus, NumPy arrays can perform vectorized operations on the whole array: better than using lists; NumPy uses an optimized C API for those operations which make them especially fast. We learn how to transform a multidimensional array into a one dimensional array, how to stack, split, convert, copy and view them by playing with images, doing tricks with Sudoku and audio arrays.In Chapter 3 we are ready to learn Basic Data Analysis by working on a genuine (and quite completely) data set by looking for evidence of planetary heating.Chapter 4 is about Predictive Analysis and the use of the ‘pandas’ library. Pandas have plotting subroutines and in this chapter data of previous chapter is re-examined and extended to correlating weather and stocks!Now, in Chapter 5 we focus on ‘Signal Processing Techniques’ and analyze time series. The example data set will be sunspot data which we sift and plot to show the extremes of Sun activity. Tools as ‘moving averages’ and smoothing functions are introduced and we are ready to do a forecasting using an ARMA (autoregressive moving average) model. Then we learn how to design and use a filter and the “cointegration”, a better metric to define the relatedness of two time series.In Chapter 6 the book moves into Profiling, Debugging and Testing. NumPy adds the numpy.testing package (and its utility functions) to help NumPy code the unit testing. Later we met Nose, a Python framework that eases unit testing by organizing it.Chapter 7 relates to the Scientific Python Ecosystem. Scipy is built on NumPy and adds functionality as numerical integration, interpolation, optimization, statistics, clustering with scikit-learn, the detection of corners (all with examples), the use of Cython with NumPy and compares NumPy to Blaze (a collection of libraries being built towards the goal of generalizing NumPy ‘s data model and working on distributed data.)This book is a complete hands-on guide on the use of NumPy, through worked examples and ideas, a must have for those interested in Data Analysis, Forecasting and Signal Processing Techniques.
Amazon Verified review Amazon
Sujit Pal Jun 21, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Numpy is a fast matrix library that is at the core of scientific computing toolkits in Python - whether you are doing statistics, machine learning or signal processing (to name just a few possibilities), chances are you are using Numpy under the covers. Because Numpy is optimized for speed and because you are often dealing with large datasets, knowing the right function to call can mean the difference between run times of a few seconds or a few hours. This book can help you write cleaner and faster Numpy code.After a quick introduction to Numpy in Chapter 1, Chapter 2 takes the reader through a quick tour of Numpy functions, describing the major ones, including differently named functions which do the same thing, one updating in place and the other creating a copy. Chapter 3-5 on is all case studies, mostly about Time Series Analysis and Signal Processing, perhaps because they are good vehicles for demonstrating array handling techniques, but a nice side effect is that it gives the reader a quick introduction to these subjects as well. Chapter 6 describes Numpy's unit testing functionality, and also covers Python unit testing frameworks (unittest package as well as nose). It also describes how to profile and debug Python code from the IPython shell. Chapter 7 quickly covers various other players in the scientific Python ecosystem, and describes how to optimize Python code by rewriting them to Cython.I found the book immensely informative and relatively easy to read. It helps to actually work through the code in a Python shell as you are reading the book, in some cases the author condenses multiple steps into a single one, obviously expecting the reader to follow along, so being able to break the steps into smaller ones can help in understanding. Using the shell also gives you access to Python's help system, so you can read about new functions as you encounter them. One minor nit - it would have been more convenient if the data used for the analysis could have been packaged with the code for the book (for people reading the book offline) - but perhaps there are copyright restrictions on such distribution.DISCLAIMER: I didn't purchase this book, a PackT representative in my social network was offering free copies to review, and I asked for one because (a) I use Numpy and wanted to learn more and (b) as a Numpy user, I felt qualified to review the book objectively.
Amazon Verified review Amazon
Daniel R. Vallejo Sep 28, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
great
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