You are previewing Learning NumPy Array.
O'Reilly logo
Learning NumPy Array

Book Description

Supercharge your scientific Python computations by understanding how to use the NumPy library effectively

In Detail

NumPy is an extension of Python, which provides highly optimized arrays and numerical operations. NumPy replaces a lot of the functionality of Matlab and Mathematica specifically vectorized operations, but in contrast to those products is free and open source. In today's world of science and technology, it is all about speed and flexibility.

This book will teach you about NumPy, a leading scientific computing library. This book enables you to write readable, efficient, and fast code, which is closely associated to the language of mathematics. Save thousands of dollars on expensive software, while keeping all the flexibility and power of your favorite programming language.

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. Learning NumPy Array will help you be productive with NumPy and write clean and fast code.

What You Will Learn

  • Install NumPy and discover its arrays and features
  • Perform data analysis and complex array operations with NumPy
  • Analyze time series and perform signal processing
  • Understand NumPy modules and explore the scientific Python ecosystem
  • Improve the performance of calculations with clean and efficient NumPy code
  • Analyze large data sets using statistical functions and execute complex linear algebra and mathematical computations
  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

    Table of Contents

    1. Learning NumPy Array
      1. Table of Contents
      2. Learning NumPy Array
      3. Credits
      4. About the Author
      5. About the Reviewers
        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 NumPy
        1. Python
        2. Installing NumPy, Matplotlib, SciPy, and IPython on Windows
        3. Installing NumPy, Matplotlib, SciPy, and IPython on Linux
        4. Installing NumPy, Matplotlib, and SciPy on Mac OS X
        5. Building from source
        6. NumPy arrays
          1. Adding arrays
        7. Online resources and help
        8. Summary
      9. 2. NumPy Basics
        1. The NumPy array object
          1. The advantages of using NumPy arrays
        2. Creating a multidimensional array
        3. Selecting array elements
        4. NumPy numerical types
          1. Data type objects
          2. Character codes
          3. dtype constructors
          4. dtype attributes
        5. Creating a record data type
        6. One-dimensional slicing and indexing
        7. Manipulating array shapes
          1. Stacking arrays
          2. Splitting arrays
          3. Array attributes
          4. Converting arrays
        8. Creating views and copies
        9. Fancy indexing
        10. Indexing with a list of locations
        11. Indexing arrays with Booleans
        12. Stride tricks for Sudoku
        13. Broadcasting arrays
        14. Summary
      10. 3. Basic Data Analysis with NumPy
        1. Introducing the dataset
        2. Determining the daily temperature range
        3. Looking for evidence of global warming
        4. Comparing solar radiation versus temperature
        5. Analyzing wind direction
        6. Analyzing wind speed
        7. Analyzing precipitation and sunshine duration
        8. Analyzing monthly precipitation in De Bilt
        9. Analyzing atmospheric pressure in De Bilt
        10. Analyzing atmospheric humidity in De Bilt
        11. Summary
      11. 4. Simple Predictive Analytics with NumPy
        1. Examining autocorrelation of average temperature with pandas
        2. Describing data with pandas DataFrames
        3. Correlating weather and stocks with pandas
        4. Predicting temperature
          1. Autoregressive model with lag 1
          2. Autoregressive model with lag 2
        5. Analyzing intra-year daily average temperatures
        6. Introducing the day-of-the-year temperature model
        7. Modeling temperature with the SciPy leastsq function
        8. Day-of-year temperature take two
        9. Moving-average temperature model with lag 1
        10. The Autoregressive Moving Average temperature model
        11. The time-dependent temperature mean adjusted autoregressive model
        12. Outliers analysis of average De Bilt temperature
        13. Using more robust statistics
        14. Summary
      12. 5. Signal Processing Techniques
        1. Introducing the Sunspot data
          1. Sifting continued
        2. Moving averages
        3. Smoothing functions
        4. Forecasting with an ARMA model
        5. Filtering a signal
          1. Designing the filter
        6. Demonstrating cointegration
        7. Summary
      13. 6. Profiling, Debugging, and Testing
        1. Assert functions
          1. The assert_almost_equal function
          2. Approximately equal arrays
          3. The assert_array_almost_equal function
        2. Profiling a program with IPython
        3. Debugging with IPython
        4. Performing Unit tests
        5. Nose tests decorators
        6. Summary
      14. 7. The Scientific Python Ecosystem
        1. Numerical integration
        2. Interpolation
        3. Using Cython with NumPy
        4. Clustering stocks with scikit-learn
        5. Detecting corners
        6. Comparing NumPy to Blaze
        7. Summary
      15. Index