NumPy Cookbook - Second Edition

Over 90 fascinating recipes to learn and perform mathematical, scientific, and engineering Python computations with NumPy

NumPy Cookbook - Second Edition

This ebook is included in a Mapt subscription
Ivan Idris

2 customer reviews
Over 90 fascinating recipes to learn and perform mathematical, scientific, and engineering Python computations with NumPy
$0.00
$35.99
$44.99
$29.99p/m after trial
RRP $35.99
RRP $44.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 4,000+ eBooks & Videos
  • 40+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781784390945
Paperback258 pages

Book Description

NumPy has the ability to give you speed and high productivity. High performance calculations can be done easily with clean and efficient code, and it allows you to execute complex algebraic and mathematical computations in no time.

This book will give you a solid foundation in NumPy arrays and universal functions. Starting with the installation and configuration of IPython, you'll learn about advanced indexing and array concepts along with commonly used yet effective functions. You will then cover practical concepts such as image processing, special arrays, and universal functions. You will also learn about plotting with Matplotlib and the related SciPy project with the help of examples. At the end of the book, you will study how to explore atmospheric pressure and its related techniques. By the time you finish this book, you'll be able to write clean and fast code with NumPy.

Table of Contents

Chapter 1: Winding Along with IPython
Introduction
Installing IPython
Using IPython as a shell
Reading manual pages
Installing matplotlib
Running an IPython notebook
Exporting an IPython notebook
Importing a web notebook
Configuring a notebook server
Exploring the SymPy profile
Chapter 2: Advanced Indexing and Array Concepts
Introduction
Installing SciPy
Installing PIL
Resizing images
Creating views and copies
Flipping Lena
Fancy indexing
Indexing with a list of locations
Indexing with Booleans
Stride tricks for Sudoku
Broadcasting arrays
Chapter 3: Getting to Grips with Commonly Used Functions
Introduction
Summing Fibonacci numbers
Finding prime factors
Finding palindromic numbers
The steady state vector
Discovering a power law
Trading periodically on dips
Simulating trading at random
Sieving integers with the Sieve of Eratosthenes
Chapter 4: Connecting NumPy with the Rest of the World
Introduction
Using the buffer protocol
Using the array interface
Exchanging data with MATLAB and Octave
Installing RPy2
Interfacing with R
Installing JPype
Sending a NumPy array to JPype
Installing Google App Engine
Deploying the NumPy code on the Google Cloud
Running the NumPy code in a PythonAnywhere web console
Chapter 5: Audio and Image Processing
Introduction
Loading images into memory maps
Combining images
Blurring images
Repeating audio fragments
Generating sounds
Designing an audio filter
Edge detection with the Sobel filter
Chapter 6: Special Arrays and Universal Functions
Introduction
Creating a universal function
Finding Pythagorean triples
Performing string operations with chararray
Creating a masked array
Ignoring negative and extreme values
Creating a scores table with a recarray function
Chapter 7: Profiling and Debugging
Introduction
Profiling with timeit
Profiling with IPython
Installing line_profiler
Profiling code with line_profiler
Profiling code with the cProfile extension
Debugging with IPython
Debugging with PuDB
Chapter 8: Quality Assurance
Introduction
Installing Pyflakes
Performing static analysis with Pyflakes
Analyzing code with Pylint
Performing static analysis with Pychecker
Testing code with docstrings
Writing unit tests
Testing code with mocks
Testing the BDD way
Chapter 9: Speeding Up Code with Cython
Introduction
Installing Cython
Building a Hello World program
Using Cython with NumPy
Calling C functions
Profiling the Cython code
Approximating factorials with Cython
Chapter 10: Fun with Scikits
Introduction
Installing scikit-learn
Loading an example dataset
Clustering Dow Jones stocks with scikits-learn
Installing statsmodels
Performing a normality test with statsmodels
Installing scikit-image
Detecting corners
Detecting edges
Installing pandas
Estimating correlation of stock returns with pandas
Loading data as pandas objects from statsmodels
Resampling time series data
Chapter 11: Latest and Greatest NumPy
Introduction
Fancy indexing in place for ufuncs with the at() method
Partial sorting via selection for fast median with the partition() function
Skipping NaNs with the nanmean(), nanvar(), and nanstd() functions
Creating value initialized arrays with the full() and full_like() functions
Random sampling with numpy.random.choice()
Using the datetime64 type and related API
Chapter 12: Exploratory and Predictive Data Analysis with NumPy
Introduction
Exploring atmospheric pressure
Exploring the day-to-day pressure range
Studying annual atmospheric pressure averages
Analyzing maximum visibility
Predicting pressure with an autoregressive model
Predicting pressure with a moving average model
Studying intrayear average pressure
Studying extreme values of atmospheric pressure

What You Will Learn

  • Learn advanced indexing and linear algebra
  • Deal with missing stock price data using masked arrays
  • Explore everything you need to know about image processing
  • Dive into broadcasting and histograms
  • Profile NumPy code and visualize the results
  • Speed up your code with Cython
  • Use universal functions and interoperability features
  • Analyze your performance using Quality Assurance
  • Learn about exploratory and predictive data analysis with NumPy

Authors

Table of Contents

Chapter 1: Winding Along with IPython
Introduction
Installing IPython
Using IPython as a shell
Reading manual pages
Installing matplotlib
Running an IPython notebook
Exporting an IPython notebook
Importing a web notebook
Configuring a notebook server
Exploring the SymPy profile
Chapter 2: Advanced Indexing and Array Concepts
Introduction
Installing SciPy
Installing PIL
Resizing images
Creating views and copies
Flipping Lena
Fancy indexing
Indexing with a list of locations
Indexing with Booleans
Stride tricks for Sudoku
Broadcasting arrays
Chapter 3: Getting to Grips with Commonly Used Functions
Introduction
Summing Fibonacci numbers
Finding prime factors
Finding palindromic numbers
The steady state vector
Discovering a power law
Trading periodically on dips
Simulating trading at random
Sieving integers with the Sieve of Eratosthenes
Chapter 4: Connecting NumPy with the Rest of the World
Introduction
Using the buffer protocol
Using the array interface
Exchanging data with MATLAB and Octave
Installing RPy2
Interfacing with R
Installing JPype
Sending a NumPy array to JPype
Installing Google App Engine
Deploying the NumPy code on the Google Cloud
Running the NumPy code in a PythonAnywhere web console
Chapter 5: Audio and Image Processing
Introduction
Loading images into memory maps
Combining images
Blurring images
Repeating audio fragments
Generating sounds
Designing an audio filter
Edge detection with the Sobel filter
Chapter 6: Special Arrays and Universal Functions
Introduction
Creating a universal function
Finding Pythagorean triples
Performing string operations with chararray
Creating a masked array
Ignoring negative and extreme values
Creating a scores table with a recarray function
Chapter 7: Profiling and Debugging
Introduction
Profiling with timeit
Profiling with IPython
Installing line_profiler
Profiling code with line_profiler
Profiling code with the cProfile extension
Debugging with IPython
Debugging with PuDB
Chapter 8: Quality Assurance
Introduction
Installing Pyflakes
Performing static analysis with Pyflakes
Analyzing code with Pylint
Performing static analysis with Pychecker
Testing code with docstrings
Writing unit tests
Testing code with mocks
Testing the BDD way
Chapter 9: Speeding Up Code with Cython
Introduction
Installing Cython
Building a Hello World program
Using Cython with NumPy
Calling C functions
Profiling the Cython code
Approximating factorials with Cython
Chapter 10: Fun with Scikits
Introduction
Installing scikit-learn
Loading an example dataset
Clustering Dow Jones stocks with scikits-learn
Installing statsmodels
Performing a normality test with statsmodels
Installing scikit-image
Detecting corners
Detecting edges
Installing pandas
Estimating correlation of stock returns with pandas
Loading data as pandas objects from statsmodels
Resampling time series data
Chapter 11: Latest and Greatest NumPy
Introduction
Fancy indexing in place for ufuncs with the at() method
Partial sorting via selection for fast median with the partition() function
Skipping NaNs with the nanmean(), nanvar(), and nanstd() functions
Creating value initialized arrays with the full() and full_like() functions
Random sampling with numpy.random.choice()
Using the datetime64 type and related API
Chapter 12: Exploratory and Predictive Data Analysis with NumPy
Introduction
Exploring atmospheric pressure
Exploring the day-to-day pressure range
Studying annual atmospheric pressure averages
Analyzing maximum visibility
Predicting pressure with an autoregressive model
Predicting pressure with a moving average model
Studying intrayear average pressure
Studying extreme values of atmospheric pressure

Book Details

ISBN 139781784390945
Paperback258 pages
Read More
From 2 reviews

Read More Reviews