You are previewing Learning IPython for Interactive Computing and Data Visualization.
O'Reilly logo
Learning IPython for Interactive Computing and Data Visualization

Book Description

IPython provides a rich architecture for interactive computing, and as a Python developer you can take advantage of this practical hands-on guide to make yourself an expert. Covers numerical computing, data analysis, and more.

  • A practical step-by-step tutorial which will help you to replace the Python console with the powerful IPython command-line interface

  • Use the IPython notebook to modernize the way you interact with Python

  • Perform highly efficient computations with NumPy and Pandas

  • Optimize your code using parallel computing and Cython

  • In Detail

    You already use Python as a scripting language, but did you know it is also increasingly used for scientific computing and data analysis? Interactive programming is essential in such exploratory tasks and IPython is the perfect tool for that. Once you’ve learnt it, you won’t be able to live without it.

    "Learning IPython for Interactive Computing and Data Visualization" is a practical, hands-on, example-driven tutorial to considerably improve your productivity during interactive Python sessions, and shows you how to effectively use IPython for interactive computing and data analysis.

    This book covers all aspects of IPython, from the highly powerful interactive Python console to the numerical and visualization features that are commonly associated with IPython.

    You will learn how IPython lets you perform efficient vectorized computations, through examples covering numerical simulations with NumPy, data analysis with Pandas, and visualization with Matplotlib. You will also discover how IPython can be conveniently used to optimize your code using parallel computing and dynamic compilation in C with Cython.

    "Learning IPython for Interactive Computing and Data Visualization" will allow you to optimize your productivity in interactive Python sessions.

    Table of Contents

    1. Learning IPython for Interactive Computing and Data Visualization
      1. Table of Contents
      2. Learning IPython for Interactive Computing and Data Visualization
      3. Credits
      4. About the Author
      5. About the Reviewer
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Getting Started with IPython
        1. Installing IPython and the recommended packages
          1. Prerequisites for IPython
          2. Installing an all-in-one distribution
          3. Installing the packages one by one
            1. Packages websites
            2. Getting binary installers
              1. Windows
              2. OS X
              3. Linux
              4. Table of binary packages
            3. Using the Python packaging system
              1. Optional dependencies for IPython
          4. Installing the development versions
        2. Ten IPython essentials
          1. Running the IPython console
          2. Using IPython as a system shell
          3. Using the history
          4. Tab completion
          5. Executing a script with the %run command
          6. Quick benchmarking with the %timeit command
          7. Quick debugging with the %debug command
          8. Interactive computing with Pylab
          9. Using the IPython Notebook
          10. Customizing IPython
        3. Summary
      9. 2. Interactive Work with IPython
        1. The extended shell
          1. Navigating through the filesystem
          2. Accessing the system shell from IPython
        2. The extended Python console
          1. Exploring the history
          2. Import/export of Python code
            1. Importing code in IPython
            2. Exporting code to a file
          3. Dynamic introspection
            1. Tab completion
              1. An example of tab completion NetworkX
              2. Tab completion with custom classes
            2. Source code introspection
          4. Using the interactive debugger
          5. Interactive benchmarking and profiling
            1. Controlling the execution time of a command
            2. Profiling a script
        3. Using the IPython notebook
          1. Installation
          2. The notebook dashboard
          3. Working with cells
          4. Cell magics
          5. Managing notebooks
          6. Multimedia and rich text editing
          7. Graph plotting
        4. Summary
      10. 3. Numerical Computing with IPython
        1. A primer to vector computing
          1. An example of computation with Python loops
          2. What an array is
          3. Reimplementing the example with arrays
        2. Creating and loading arrays
          1. Creating arrays
            1. From scratch, element by element
            2. From scratch, using predefined templates
            3. From random values
          2. Loading arrays
            1. From a native Python object
            2. From a buffer or an external file
            3. Using Pandas
        3. Working with arrays
          1. Selection
            1. Using Pandas
            2. Using NumPy
            3. More indexing possibilities
          2. Manipulation
            1. Reshaping
            2. Repeating and concatenating
            3. Broadcasting
            4. Permuting
          3. Computation
        4. Advanced mathematical processing
        5. Summary
      11. 4. Interactive Plotting and Graphical Interfaces
        1. Figures with Matplotlib
          1. Setting up IPython for interactive visualization
            1. Using Matplotlib
            2. Interactive navigation
            3. Matplotlib in the IPython notebook
          2. Standard plots
            1. Curves
            2. Scatter plots
            3. Bar graphs
          3. Plot customization
            1. Styles and colors
            2. Grid, axes, and legends
            3. Interaction from IPython
            4. Drawing multiple plots
        2. Advanced figures and graphics
          1. Image processing
            1. Loading images
            2. Showing images
            3. Using PIL
            4. Advanced image processing – color quantization
          2. Maps
          3. 3D plots
          4. Animations
          5. Other visualization packages
        3. Graphical User Interfaces (GUI)
          1. Setting up IPython for interactive GUIs
          2. A "Hello World" example
        4. Summary
      12. 5. High-Performance and Parallel Computing
        1. Interactive task parallelization
          1. Parallel computing in Python
          2. Distributing tasks on multiple cores
            1. Starting the engines
            2. Creating a Client instance
            3. Using the parallel magic
            4. Parallel map
              1. Creating a view
              2. Synchronous map
              3. Asynchronous map
          3. A practical example – Monte Carlo simulations
          4. Using MPI with IPython
          5. Advanced parallel computing features of IPython
        2. Using C in IPython with Cython
          1. Installing and configuring Cython
          2. Using Cython from IPython
          3. Accelerating a pure Python algorithm with Cython
            1. Pure Python version
            2. Naïve Cython conversion
            3. Adding C types
          4. Using NumPy and Cython
            1. Python version
            2. Cython version
          5. More advanced options for accelerating Python code
        3. Summary
      13. 6. Customizing IPython
        1. IPython profiles
          1. Profile locations
          2. The IPython configuration files
          3. Loading scripts when IPython starts
        2. IPython extensions
          1. Example – line-by-line profiling
          2. Creating new extensions
            1. Example – executing C++ code in IPython
        3. Rich representations in the frontend
        4. Embedding IPython
        5. Final words
        6. Summary
      14. Index