Numpy Cookbook (Python)

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Author(s): Ivan Idris
Edition: 2
Publisher: Packt Publishing
Year: 2015

Language: English
Pages: 258

Cover
Copyright
Credits
About the Author
About the Reviewers
www.PacktPub.com
Table of Contents
Preface
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
Index