Use your business data to your advantage with the help of Syncfusion’s new data science offerings. Discover how a custom big data solution can provide your company with valuable predictions about key market trends.

NumPy Cookbook

Cookbook

Ivan Idris October 2012

If you’re a Python developer with basic NumPy skills, the 70+ recipes in this brilliant cookbook will boost your skills in no time. Learn to raise productivity levels and code faster and cleaner with the open source mathematical library.

$26.99

$44.99

RRP $26.99

RRP $44.99

eBook

Print + eBook

Want this title & more?

$21.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781849518925

Paperback226 pages

About This Book

Do high performance calculations with clean and efficient NumPy code

Analyze large sets of data with statistical functions

Execute complex linear algebra and mathematical computations

Who This Book Is For

This book will take Python developers with basic Numpy skills to the next level through some practical recipes.

Table of Contents

Chapter 1: Winding Along with IPython

Introduction

Installing IPython

Using IPython as a shell

Reading manual pages

Installing Matplotlib

Running a web notebook

Exporting a web 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: Get to Grips with Commonly Used Functions

Introduction

Summing Fibonacci numbers

Finding prime factors

Finding palindromic numbers

The steady state vector determination

Discovering a power law

Trading periodically on dips

Simulating trading at random

Sieving integers with the Sieve of Erasthothenes

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 NumPy code in the Google cloud

Running NumPy code in a Python Anywhere web console

Setting up PiCloud

Chapter 5: Audio and Image Processing

Introduction

Loading images into memory map

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 recarray

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

Chapter 9: Speed Up Code with Cython

Introduction

Installing Cython

Building a Hello World program

Using Cython with NumPy

Calling C functions

Profiling Cython code

Approximating factorials with Cython

Chapter 10: Fun with Scikits

Introduction

Installing scikits-learn

Loading an example dataset

Clustering Dow Jones stocks with scikits-learn

Installing scikits-statsmodels

Performing a normality test with scikits-statsmodels

Installing scikits-image

Detecting corners

Detecting edges

Installing Pandas

Estimating stock returns correlation with Pandas

Loading data as pandas objects from statsmodels

Resampling time series data

What You Will Learn

Learn advanced Indexing and linear algebra

Know reshaping automatically

Dive into Broadcasting and Histograms

Profile NumPy code and visualize your profiling results

Speed up your code with Cython

Use the array interface to expose foreign memory to NumPy

Use universal functions and interoperability features

Learn about Matplotlib and Scipy which is often used in conjunction with Numpy

In Detail

Today's world of science and technology is all about speed and flexibility. When it comes to scientific computing, NumPy is on the top of the list. NumPy will give you both speed and high productivity.

"NumPy Cookbook" will teach you all about NumPy, a leading scientific computing library. NumPy replaces a lot of the functionality of Matlab and Mathematica, but in contrast to those products, it is free and open source.

"Numpy Cookbook" will teach you to write readable, efficient, and fast code that is as close to the language of Mathematics as much as possible with the cutting edge open source NumPy software library.

You will learn about installing and using NumPy and related concepts. At the end of the book, we will explore related scientific computing projects.

This book will give you a solid foundation in NumPy arrays and universal functions. You will also learn about plotting with Matplotlib and the related SciPy project through examples.

"NumPy Cookbook" will help you to be productive with NumPy and write clean and fast code.

Authors

Ivan Idris

Ivan Idris has an MSc in experimental physics. His graduation thesis had a strong emphasis on applied computer science. After graduating, he worked for several companies as a software developer, data warehouse developer, and QA analyst. His main professional interests are business intelligence, big data, and cloud computing. Ivan Idris enjoys writing clean testable code and interesting technical articles. Ivan Idris is the author of NumPy Beginner's Guide, NumPy Cookbook, Learning NumPy Array, and Python Data Analysis (see https://www.packtpub.com/books/info/authors/ivan-idris). You can find more information and a blog with a few NumPy examples at http://ivanidris.net/wordpress/.

Alerts & Offers

Series & Level

We understand your time is important. Uniquely amongst the major publishers, we seek to develop and publish the broadest range of learning and information products on each technology. Every Packt product delivers a specific learning pathway, broadly defined by the Series type. This structured approach enables you to select the pathway which best suits your knowledge level, learning style and task objectives.

Learning

As a new user, these step-by-step tutorial guides will give you all the practical skills necessary to become competent and efficient.

Beginner's Guide

Friendly, informal tutorials that provide a practical introduction using examples, activities, and challenges.

Essentials

Fast paced, concentrated introductions showing the quickest way to put the tool to work in the real world.

Cookbook

A collection of practical self-contained recipes that all users of the technology will find useful for building more powerful and reliable systems.

Blueprints

Guides you through the most common types of project you'll encounter, giving you end-to-end guidance on how to build your specific solution quickly and reliably.

Mastering

Take your skills to the next level with advanced tutorials that will give you confidence to master the tool's most powerful features.

Starting

Accessible to readers adopting the topic, these titles get you into the tool or technology so that you can become an effective user.

Progressing

Building on core skills you already have, these titles share solutions and expertise so you become a highly productive power user.