Home Big-data-and-business-intelligence NumPy Cookbook - Second Edition

NumPy Cookbook - Second Edition

By Ivan Idris
books-svg-icon Book
Subscription
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
Subscription
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
  1. Free Chapter
    Winding Along with IPython
About this book

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.

Publication date:
April 2015
Publisher
Packt
Pages
258
ISBN
9781784390945

 

Chapter 1. Winding Along with IPython

In this chapter, we will cover the following recipes:

  • 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

 

Introduction


IPython, which is available at http://ipython.org/, is a free, open source project available for Linux, Unix, Mac OS X, and Windows. The IPython authors only request that you cite IPython in any scientific work where IPython was used. IPython provides an architecture for interactive computing. The most notable part of this project is the IPython shell. IPython provides the following components, among others:

  • Interactive Python shells (terminal-based and Qt application)

  • A web notebook (available in IPython 0.12 and later) with support for rich media and plotting

IPython is compatible with Python versions 2.5, 2.6, 2.7, 3.1, 3.2, 3.3, and 3.4. The compatibility depends on the IPython version. For instance, IPython 2.3.0 requires Python 2.7 or 3.3+.

You can try IPython in the cloud without installing it on your system by going to http://www.pythonanywhere.com/try-ipython/. There is a slight delay compared to locally installed software, so this is not as good as the real thing. However, most of the features available in the IPython interactive shell seem to be available. PythonAnywhere also has a Vi (m) editor, which if you like vi, is obviously great. You can save and edit files from your IPython sessions.

 

Installing IPython


IPython can be installed in various ways, depending on your operating system. For the terminal-based shell, there is a dependency on readline. The web notebook requires tornado and zmq.

In addition to installing IPython, we will install setuptools, which gives you the easy_install command. The easy_install command is a popular package manager for Python. pip can be installed once you have easy_install. The pip command is similar to easy_install and adds options such as uninstalling.

How to do it...

This section describes how IPython can be installed on Windows, Mac OS X, and Linux. It also describes how to install IPython and its dependencies with easy_install and pip, or from source:

  • Installing IPython and setuptools on Windows: A binary Windows installer for Python 2 or Python 3 is available on the IPython website. Also see http://ipython.org/ipython-doc/stable/install/install.html#windows.

    Install setuptools with an installer from http://pypi.python.org/pypi/setuptools#files. Then install pip, like this:

    cd C:\Python27\scripts
    python .\easy_install-27-script.py pip
    
  • Installing IPython on Mac OS X: Install the Apple Developer Tools (Xcode) if necessary. Xcode can be found at https://developer.apple.com/xcode/. Follow the easy_install/pip instructions or the instructions for installation from source provided later in this section.

  • Installing IPython on Linux: Since there are so many Linux distributions, this section will not be exhaustive:

    • On Debian, type the following command:

      $ su – aptitude install ipython python-setuptools
      
    • On Fedora, the magic command is as follows:

      $ su – yum install ipython python-setuptools-devel
      
    • The following command will install IPython on Gentoo:

      $ su – emerge ipython
      
    • For Ubuntu, the install command is as follows:

      $ sudo apt-get install ipython python-setuptools
      
  • Installing IPython with easy_install or pip: Install IPython and all the dependencies required for the recipes in this chapter with easy_install using the following command:

    $ sudo easy_install ipython pyzmq tornado readline
    

    Alternatively, you can first install pip with easy_install by typing this command in your terminal:

    $ sudo easy_install pip
    

    After that, install IPython using pip:

    $ sudo pip install ipython pyzmq tornado readline
    
  • Installing from source: If you want to use the bleeding-edge development version, then installing from source is for you:

    1. Download the latest source archive from https://github.com/ipython/ipython/archive/master.zip.

    2. Unpack the source code from the archive:

      $ tar xzf ipython-<version>.tar.gz
      
    3. Instead, if you have Git installed, you can clone the Git repository:

      $ git clone https://github.com/ipython/ipython.git
      
    4. Go to the root directory within the downloaded source:

      $ cd ipython
      
    5. Run the setup script. This may require you to run the command with sudo, as follows:

      $ sudo python setup.py install
      

How it works...

We installed IPython using several methods. Most of these methods install the latest stable release, except when you install from source, which will install the development version.

See also

 

Using IPython as a shell


Scientists and engineers are used to experimenting. IPython was created by scientists with experimentation in mind. The interactive environment that IPython provides is viewed by many as a direct answer to MATLAB, Mathematica, Maple, and R.

The following is a list of features of the IPython shell:

  • Tab completion

  • History mechanism

  • Inline editing

  • The ability to call external Python scripts with %run

  • The ability to call magic functions that interact with the operating system shell

  • Access to system commands

  • The pylab switch

  • Access to Python debugger and profiler

How to do it...

This section describes how to use the IPython shell:

  • pylab: The pylab switch automatically imports all the SciPy, NumPy, and matplotlib packages. Without this switch, we would have to import these packages ourselves.

    All we need to do is enter the following instruction on the command line:

    $ ipython --pylab
    Type "copyright", "credits" or "license" for more information.
    
    IPython 2.4.1 -- An enhanced Interactive Python.
    ?         -> Introduction and overview of IPython's features.
    %quickref -> Quick reference.
    help      -> Python's own help system.
    object?   -> Details about 'object', use 'object??' for extra details.
    
    Welcome to pylab, a matplotlib-based Python environment [backend: MacOSX].
    For more information, type 'help(pylab)'.
    
    In [1]: quit()
    quit() or Ctrl + D quits the IPython shell.
    
  • Saving a session: We might want to be able to go back to our experiments. In IPython, it is easy to save a session for later use. This is done with the following command:

    In [1]: %logstart
    Activating auto-logging. Current session state plus future input saved.
    Filename       : ipython_log.py
    Mode           : rotate
    Output logging : False
    Raw input log  : False
    Timestamping   : False
    State          : active
    

    Logging can be switched off using this command:

    In [9]: %logoff
    Switching logging OFF
    
  • Executing a system shell command: You can execute a system shell command in the default IPython profile by prefixing the command with the ! symbol. For instance, the following input will get the current date:

    In [1]: !date
    

    In fact, any line prefixed with ! is sent to the system shell. We can also store the command output, as shown here:

    In [2]: thedate = !date
    In [3]: thedate
    
  • Displaying history: We can show the history of commands with the %hist command, like this:

    In [1]: a = 2 + 2
    
    In [2]: a
    Out[2]: 4
    
    In [3]: %hist
    a = 2 + 2
    a
    %hist
    

    This is a common feature in Command-line Interface (CLI) environments. We can also look up the history with the -g switch:

    In [5]: %hist -g a = 2
        1: a = 2 + 2
    

Tip

Downloading the example code

You can download the example code files for all Packt Publishing books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to get the files e-mailed directly to you.

How it works...

We saw a number of so-called magic functions in action. These functions start with the % character. If a magic function is used in a line by itself, the % prefix is optional.

See also

 

Reading manual pages


We can open the documentation for NumPy functions with the help command. It is not necessary to know the name of a function. We can type a few characters and then let tab completion do its work. For instance, let's browse the available information for the arange() function.

How to do it...

We can browse the available information in either of the following ways:

  • Calling the help function: Call the help command. Type a few characters of the function and then press the Tab key (see the following screenshot):

  • Querying with a question mark: Another option is to put a question mark behind the function name. You will then, of course, need to know the function name, but you don't have to type the help command:

    In [3]: arange?
    

How it works...

Tab completion is dependent on readline, so you need to make sure it is installed. The question mark gives you information from docstrings.

 

Installing matplotlib


matplotlib (all lowercase by convention) is a very useful Python plotting library, and we will need it for the following recipes as well as more later on. It depends on NumPy, but in all likelihood, you already have NumPy installed.

How to do it...

We will see how matplotlib can be installed on Windows, Linux, and Mac OS X, and also how to install it from source:

  • Installing matplotlib on Windows: You can install this with the Enthought distribution, also known as Canopy (http://www.enthought.com/products/epd.php).

    It might be necessary to put the msvcp71.dll file in your C:\Windows\system32 directory. You can get it from http://www.dll-files.com/dllindex/dll-files.shtml?msvcp71.

  • Installing matplotlib on Linux: Let's see how matplotlib can be installed in the various distributions of Linux:

    Here is the install command on Debian and Ubuntu:

    $ sudo apt-get install python-matplotlib
    
    • The install command on Fedora/Redhat is as follows:

      $ su - yum install python-matplotlib
      
  • Installing from source: You can download the latest source from the tar.gz release at Sourceforge (http://sourceforge.net/projects/matplotlib/files/), or from the Git repository using the following command:

    $ git clone git://github.com/matplotlib/matplotlib.git
    

    Once it has been downloaded, build and install matplotlib as usual with the following commands:

    $ cd matplotlib
    $ sudo python setup.py install
    
  • Installing matplotlib on Mac OS X: Get the latest DMG file from http://sourceforge.net/projects/matplotlib/files/matplotlib/ and install it. You can also use the Mac Ports, Fink, or Homebrew package managers.

See also

 

Running an IPython notebook


IPython has an exciting feature—the web notebook. A so-called notebook server can serve notebooks over the Web. We can now start a notebook server and get a web-based IPython environment. This environment has most of the features that the regular IPython environment has. The IPython notebook's features include the following:

  • Displaying images and inline plots

  • Using HTML and Markdown (this is a simplified HTML-like language see https://en.wikipedia.org/wiki/Markdown) in text cells

  • Importing and exporting of notebooks

Getting ready

Before we start, we should make sure that all of the required software is installed. There is a dependency on tornado and zmq. See the Installing IPython recipe in this chapter for more information.

How to do it...

  • Running a notebook: We can start a notebook with the following command:

    $ ipython notebook
    
    [NotebookApp] Using existing profile dir: u'/Users/ivanidris/.ipython/profile_default'
    [NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888
    [NotebookApp] Use Control-C to stop this server and shut down all kernels.
    

    As you can see, we are using the default profile. A server started on the local machine at port 8888. You will learn how to configure these settings later on in this chapter. The notebook is opened in your default browser; this is configurable as well (see the following screenshot):

    IPython lists all the notebooks in the directory where you started the notebook. In this example, no notebooks were found. The server can be stopped by pressing Ctrl + C.

  • Running a notebook in the pylab mode: Run a web notebook in the pylab mode with the following command:

    $ ipython notebook --pylab
    

    This loads the SciPy, NumPy, and matplotlib modules.

  • Running a notebook with inline figures: We can display inline matplotlib plots with the inline directive using the following command:

    $ ipython notebook --pylab inline
    

    The following steps demonstrate the IPython notebook functionality:

    1. Click on the New Notebook button to create a new notebook.

    2. Create an array with the arange() function. Type the command shown in the following screenshot and click on Cell/Run:

    3. Next enter the following command and press Enter. You will see the output in Out [2], as shown in the following screenshot:

    4. Apply the sinc() function to the array and plot the result, as shown in this screenshot:

How it works...

The inline option lets you display inline matplotlib plots. When combined with the pylab mode, you don't need to import the NumPy, SciPy, and matplotlib packages.

See also

 

Exporting an IPython notebook


Sometimes, you would want to exchange notebooks with friends or colleagues. The web notebook provides several methods to export your data.

How to do it...

A web notebook can be exported using the following options:

  • The Print option: The Print button doesn't actually print the notebook, but allows you to export the notebook as a PDF or HTML document.

  • Downloading the notebook: Download your notebook to a location chosen by you, using the Download button. We can specify whether we want to download the notebook as a .py file, which is just a normal Python program, or in the JSON format as a .ipynb file. The notebook we created in the previous recipe looks like the following after exporting:

    {
     "metadata": {
      "name": "Untitled1"
     }, 
     "nbformat": 2, 
     "worksheets": [
      {
        "cells": [
        {
          "cell_type": "code", 
          "collapsed": false, 
          "input": [
            "plot(sinc(a))"
          ], 
          "language": "python", 
          "outputs": [
          {
            "output_type": "pyout", 
            "prompt_number": 3, 
            "text": [
              "[&lt;matplotlib.lines.Line2D at 0x103d9c690&gt;]"
            ]
          }, 
          {
            "output_type": "display_data", 
            "png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAD9CAYAAABZVQdHAAAABHNCSVQICAgIf...
              mgkAAAAASUVORK5CYII=\n"
          }
          ], 
          "prompt_number": 3
        }
        ]
      }
      ]
    }

    Note

    Some of the text has been omitted for brevity. This file is not intended for editing or even reading, but it is pretty readable if you ignore the image representation part. For more information about JSON, see https://en.wikipedia.org/wiki/JSON.

  • Saving the notebook: Save the notebook using the Save button. This will automatically export a notebook in the native JSON format, .ipynb. The file will be stored in the directory where you started IPython initially.

 

Importing a web notebook


Python scripts can be imported as a web notebook. Obviously, we can also import previously exported notebooks.

How to do it...

This recipe shows you how a Python script can be imported as a web notebook.

Load a Python script with this command:

% load vectorsum.py

The following screenshot shows an example of what we see after loading vectorsum.py from NumPy Beginner's Guide into the notebook page:

 

Configuring a notebook server


A public notebook server needs to be secure. You should set a password and use an SSL certificate to connect to it. We need the certificate to provide secure communication over HTTPS (for more information, see https://en.wikipedia.org/wiki/Transport_Layer_Security). HTTPS adds a secure layer on top of the standard HTTP protocol widely used on the Internet. HTTPS also encrypts data sent from the client to the server and back. A certificate authority is often a commercial organization that issues certificates for websites. Web browsers have knowledge of certificate authorities and can recognize certificates. A website administrator needs to create a certificate and get it signed by a certificate authority.

How to do it...

The following steps describe how to configure a secure notebook server:

  1. We can generate a password from IPython. Start a new IPython session and type in the following commands:

    In [1]: from IPython.lib import passwd
    
    In [2]: passwd()
    Enter password: 
    Verify password: 
    Out[2]: 'sha1:0e422dfccef2:84cfbcbb3ef95872fb8e23be3999c123f862d856'
    

    At the second input line, you will be prompted for a password. You need to remember this password. A long string is generated. Copy this string because you will need it later on.

  2. To create a SSL certificate, you will need the openssl command in your path.

    Setting up the openssl command is not rocket science, but it can be tricky. Unfortunately, it is outside the scope of this book. On the brighter side, there are plenty of tutorials available online to help you further.

    Execute the following command to create a certificate with mycert.pem as the name:

    $ openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem
    Generating a 1024 bit RSA private key
    ......++++++
    ........................++++++
    writing new private key to 'mycert.pem'
    -----
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) [AU]:
    State or Province Name (full name) [Some-State]:
    Locality Name (eg, city) []:
    Organization Name (eg, company) [Internet Widgits Pty Ltd]:
    Organizational Unit Name (eg, section) []:
    Common Name (eg, YOUR name) []:
    Email Address []:
    

    The openssl utility prompts you to fill in some fields. For more information, check out the relevant man page (short for manual page) as follows:

    $ man openssl
    
  3. Create a special profile for the server using the following command:

    $ ipython profile create nbserver
    
  4. Edit the configuration file. In this example, it can be found in ~/.ipython/profile_nbserver/ipython_notebook_config.py.

    The configuration file is pretty large, so we will omit most of the lines in it. The lines that we need to change at minimum are as follows:

    c.NotebookApp.certfile = u'/absolute/path/to/your/certificate'
    c.NotebookApp.password = u'sha1:b...your password'
    c.NotebookApp.port = 9999
    

    Notice that we are pointing to the SSL certificate we created. We set a password and changed the port to 9999.

  5. Using the following command, start the server to check whether the changes worked:

    $ ipython notebook --profile=nbserver
    [NotebookApp] Using existing profile dir: u'/Users/ivanidris/.ipython/profile_nbserver'
    [NotebookApp] The IPython Notebook is running at: https://127.0.0.1:9999
    [NotebookApp] Use Control-C to stop this server and shut down all kernels.
    

    The server is running on port 9999, and you need to connect to it via https. If everything goes well, you should see a login page. Also, you will probably need to accept a security exception in your browser.

How it works...

We created a special profile for our public server. There are some sample profiles that are already present, such as the default profile. Creating a profile adds a profile_<profilename> folder to the .ipython directory with a configuration file, among others. The profile can then be loaded with the --profile=<profile_name> command-line option. We can list the profiles with the following command:

$ ipython profile list

Available profiles in IPython:
    cluster
    math
    pysh
    python3

    The first request for a bundled profile will copy it
    into your IPython directory (/Users/ivanidris/.ipython),
    where you can customize it.

Available profiles in /Users/ivanidris/.ipython:
    default
    nbserver
    sh

See also

 

Exploring the SymPy profile


IPython has a sample SymPy profile. SymPy is a Python-symbolic mathematics library. We can simplify algebraic expressions or differentiate functions, similar to Mathematica and Maple. SymPy is obviously a fun piece of software, but is not necessary for our journey through the NumPy landscape. Consider this as an optional or bonus recipe. Like a dessert, feel free to skip it, although you might miss out on the sweetest piece of this chapter.

Getting ready

Install SymPy using either easy_install or pip:

$ sudo easy_install sympy
$ sudo pip install sympy

How to do it...

The following steps will help you explore the SymPy profile:

  1. Look at the configuration file, which can be found at ~/.ipython/profile_sympy/ipython_config.py. The content is as follows:

    c = get_config()
    app = c.InteractiveShellApp
    
    # This can be used at any point in a config file to load a sub config
    # and merge it into the current one.
    load_subconfig('ipython_config.py', profile='default')
    
    lines = """
    from __future__ import division
    from sympy import *
    x, y, z, t = symbols('x y z t')
    k, m, n = symbols('k m n', integer=True)
    f, g, h = symbols('f g h', cls=Function)
    """
    
    # You have to make sure that attributes that are containers already
    # exist before using them.  Simple assigning a new list will override
    # all previous values.
    
    if hasattr(app, 'exec_lines'):
        app.exec_lines.append(lines)
    else:
        app.exec_lines = [lines]
    
    # Load the sympy_printing extension to enable nice printing of sympy expr's.
    if hasattr(app, 'extensions'):
        app.extensions.append('sympyprinting')
    else:
        app.extensions = ['sympyprinting']
    

    This code accomplishes the following:

    • Loads the default profile

    • Imports the SymPy packages

    • Defines symbols

  2. Start IPython with the SymPy profile using this command:

    $ ipython --profile=sympy
    
  3. Expand an algebraic expression using the command shown in the following screenshot:

See also

About the Author
  • 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 Java 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 1.5. Beginner's Guide and NumPy Cookbook by Packt Publishing.

    Browse publications by this author
Latest Reviews (2 reviews total)
Das Buch hat mir schon sehr gut bei einem Projekt geholfen.
A little more basic than I'd hoped and not as much explanation as I wanted. Nothing in this book helped me link my stats knowledge to the NumPy methods but I have since learned that much of the nuance can be attributed to other ways to express the statistics concepts.
NumPy Cookbook - Second Edition
Unlock this book and the full library FREE for 7 days
Start now