Learning NumPy Array
By Ivan Idris
()
About this ebook
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. You can find more information and a blog with a few NumPy examples at ivanidris.net.
Read more from Ivan Idris
Python Data Analysis Rating: 4 out of 5 stars4/5NumPy Beginner's Guide Rating: 5 out of 5 stars5/5NumPy Cookbook Rating: 5 out of 5 stars5/5NumPy: Beginner's Guide - Third Edition Rating: 4 out of 5 stars4/5Python Data Analysis: Perform data collection, data processing, wrangling, visualization, and model building using Python Rating: 0 out of 5 stars0 ratingsPython Data Analysis Cookbook Rating: 0 out of 5 stars0 ratings
Related to Learning NumPy Array
Related ebooks
Learning SciPy for Numerical and Scientific Computing - Second Edition Rating: 0 out of 5 stars0 ratingsMastering Python Regular Expressions Rating: 5 out of 5 stars5/5Building Python Real-Time Applications with Storm Rating: 0 out of 5 stars0 ratingsInteractive Applications Using Matplotlib Rating: 0 out of 5 stars0 ratingsMastering matplotlib Rating: 0 out of 5 stars0 ratingsWeb Scraping with Python Rating: 4 out of 5 stars4/5Hands-On Data Analysis with Pandas: Efficiently perform data collection, wrangling, analysis, and visualization using Python Rating: 0 out of 5 stars0 ratingsMastering Python Data Analysis Rating: 0 out of 5 stars0 ratingsGetting Started with Python Data Analysis Rating: 0 out of 5 stars0 ratingsOpenCV with Python Blueprints Rating: 5 out of 5 stars5/5Modular Programming with Python Rating: 0 out of 5 stars0 ratingsPython for Secret Agents Rating: 0 out of 5 stars0 ratingsLearning Data Mining with Python Rating: 0 out of 5 stars0 ratingsLearning IPython for Interactive Computing and Data Visualization - Second Edition Rating: 2 out of 5 stars2/5Python 3 Object Oriented Programming Rating: 4 out of 5 stars4/5Python Unlocked Rating: 0 out of 5 stars0 ratingsConceptual Programming with Python Rating: 4 out of 5 stars4/5Python for Professionals Rating: 0 out of 5 stars0 ratingsPython Data Analysis - Second Edition Rating: 0 out of 5 stars0 ratingsData Analysis with Python: Introducing NumPy, Pandas, Matplotlib, and Essential Elements of Python Programming (English Edition) Rating: 0 out of 5 stars0 ratingsGetting Started with Julia Rating: 0 out of 5 stars0 ratingsLarge Scale Machine Learning with Python Rating: 2 out of 5 stars2/5Python Machine Learning By Example Rating: 4 out of 5 stars4/5Matplotlib for Python Developers Rating: 3 out of 5 stars3/5Functional Python Programming Rating: 0 out of 5 stars0 ratingsNumPy Essentials Rating: 0 out of 5 stars0 ratingsFlask By Example Rating: 0 out of 5 stars0 ratingsNumpy Simply In Depth Rating: 5 out of 5 stars5/5Mastering Python Design Patterns Rating: 0 out of 5 stars0 ratings
Programming For You
SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5SQL: For Beginners: Your Guide To Easily Learn SQL Programming in 7 Days Rating: 5 out of 5 stars5/5Python QuickStart Guide: The Simplified Beginner's Guide to Python Programming Using Hands-On Projects and Real-World Applications Rating: 0 out of 5 stars0 ratingsC Programming For Beginners: The Simple Guide to Learning C Programming Language Fast! Rating: 5 out of 5 stars5/5HTML in 30 Pages Rating: 5 out of 5 stars5/5Tiny Python Projects: Learn coding and testing with puzzles and games Rating: 5 out of 5 stars5/5Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 5 out of 5 stars5/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5C# Programming from Zero to Proficiency (Beginner): C# from Zero to Proficiency, #2 Rating: 0 out of 5 stars0 ratingsAssembly Programming:Simple, Short, And Straightforward Way Of Learning Assembly Language Rating: 5 out of 5 stars5/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Spies, Lies, and Algorithms: The History and Future of American Intelligence Rating: 4 out of 5 stars4/5Lua Game Development Cookbook Rating: 0 out of 5 stars0 ratingsExcel 101: A Beginner's & Intermediate's Guide for Mastering the Quintessence of Microsoft Excel (2010-2019 & 365) in no time! Rating: 0 out of 5 stars0 ratingsA Slackers Guide to Coding with Python: Ultimate Beginners Guide to Learning Python Quick Rating: 0 out of 5 stars0 ratingsThe Ultimate Python Programming Guide For Beginner To Intermediate Rating: 5 out of 5 stars5/5
Reviews for Learning NumPy Array
0 ratings0 reviews
Book preview
Learning NumPy Array - Ivan Idris
Table of Contents
Learning NumPy Array
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started with NumPy
Python
Installing NumPy, Matplotlib, SciPy, and IPython on Windows
Installing NumPy, Matplotlib, SciPy, and IPython on Linux
Installing NumPy, Matplotlib, and SciPy on Mac OS X
Building from source
NumPy arrays
Adding arrays
Online resources and help
Summary
2. NumPy Basics
The NumPy array object
The advantages of using NumPy arrays
Creating a multidimensional array
Selecting array elements
NumPy numerical types
Data type objects
Character codes
dtype constructors
dtype attributes
Creating a record data type
One-dimensional slicing and indexing
Manipulating array shapes
Stacking arrays
Splitting arrays
Array attributes
Converting arrays
Creating views and copies
Fancy indexing
Indexing with a list of locations
Indexing arrays with Booleans
Stride tricks for Sudoku
Broadcasting arrays
Summary
3. Basic Data Analysis with NumPy
Introducing the dataset
Determining the daily temperature range
Looking for evidence of global warming
Comparing solar radiation versus temperature
Analyzing wind direction
Analyzing wind speed
Analyzing precipitation and sunshine duration
Analyzing monthly precipitation in De Bilt
Analyzing atmospheric pressure in De Bilt
Analyzing atmospheric humidity in De Bilt
Summary
4. Simple Predictive Analytics with NumPy
Examining autocorrelation of average temperature with pandas
Describing data with pandas DataFrames
Correlating weather and stocks with pandas
Predicting temperature
Autoregressive model with lag 1
Autoregressive model with lag 2
Analyzing intra-year daily average temperatures
Introducing the day-of-the-year temperature model
Modeling temperature with the SciPy leastsq function
Day-of-year temperature take two
Moving-average temperature model with lag 1
The Autoregressive Moving Average temperature model
The time-dependent temperature mean adjusted autoregressive model
Outliers analysis of average De Bilt temperature
Using more robust statistics
Summary
5. Signal Processing Techniques
Introducing the Sunspot data
Sifting continued
Moving averages
Smoothing functions
Forecasting with an ARMA model
Filtering a signal
Designing the filter
Demonstrating cointegration
Summary
6. Profiling, Debugging, and Testing
Assert functions
The assert_almost_equal function
Approximately equal arrays
The assert_array_almost_equal function
Profiling a program with IPython
Debugging with IPython
Performing Unit tests
Nose tests decorators
Summary
7. The Scientific Python Ecosystem
Numerical integration
Interpolation
Using Cython with NumPy
Clustering stocks with scikit-learn
Detecting corners
Comparing NumPy to Blaze
Summary
Index
Learning NumPy Array
Learning NumPy Array
Copyright © 2014 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: June 2014
Production Reference: 1060614
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78398-390-2
www.packtpub.com
Cover Image by Duraid Fatouhi (<duraidfatouhi@yahoo.com>)
Credits
Author
Ivan Idris
Reviewers
Jonathan Bright
Jaidev Deshpande
Mark Livingstone
Miklós Prisznyák
Commissioning Editor
Kartikey Pandey
Acquisition Editor
Mohammad Rizvi
Content Development Editor
Akshay Nair
Technical Editors
Shubhangi H. Dhamgaye
Shweta S. Pant
Copy Editor
Sarang Chari
Project Coordinator
Lima Danti
Proofreaders
Maria Gould
Kevin McGowen
Indexer
Hemangini Bari
Production Coordinator
Arvindkumar Gupta
Cover Work
Arvindkumar Gupta
About the Author
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. He enjoys writing clean, testable code and interesting technical articles. He is the author of NumPy 1.5 Beginner's Guide and NumPy Cookbook, Packt Publishing. You can find more information and a blog with a few NumPy examples at ivanidris.net.
I would like to take this opportunity to thank the reviewers and the team at Packt Publishing for making this book possible. Also, I would like to thank my teachers, professors, and colleagues who taught me about science and programming. Last, but not least, I would like to acknowledge my parents, family, and friends for their support.
About the Reviewers
Jonathan Bright has a BS in Electrical Engineering from Rensselaer Polytechnic Institute, and specializes in audio electronics and digital signal processing. He's been programming in Python since import antigravity (the XKCD comic mentioning Python) and contributes to the NumPy and SciPy projects.
Jaidev Deshpande is a software developer at Enthought, Inc., working on software for data analysis and visualization. He's been a research assistant at the University of Pune and Tata Institute of Fundamental Research, working on signal processing and machine learning. He has worked on Numpy Cookbook, Ivan Idris, Packt Publishing.
Mark Livingstone started his career working for many years for three international computer companies (which no longer exist) in engineering/support/programming/training roles but got tired of being made redundant. He then graduated from Griffith University, Gold Coast, Australia, with a bachelor's degree in Information Technology in 2011. In 2013, he graduated with an honors in B.InfoTech and is currently pursuing his PhD. All his research software is written in Python on a Mac.
Mark enjoys mentoring students with special needs. He is a past chairperson of the IEEE Griffith University Gold Coast Student Branch, volunteers as a qualified Justice of the Peace at the local district courthouse and has been a Credit Union Director. He has also completed 104 blood donations.
In his spare time, he co-develops the Salstat2 statistics package available at https://sourceforge.net/projects/s2statistical/, which is multiplatform and uses wxPython, NumPy, SciPy, Scikit, Matplotlib, and a number of other Python modules.
Miklós Prisznyák is a senior software engineer with a scientific background. He graduated as a physicist from the Eötvös Lóránd University, the largest and oldest university in Hungary. He did his MSc thesis on Monte Carlo simulations of non-Abelian lattice quantum field theories in 1992. Having worked for three years in the Central Research Institute for Physics of Hungary, he joined MultiRáció Kft. in Budapest, a company founded by physicists, which specializes in mathematical data analysis and forecasting economic data.
His main project was the Small Area Unemployment Statistics System, which has been in official use at the Hungarian Public Employment Service since then. He learned about the Python programming language there in 2000. He set up his own consulting company in 2002 and then worked on various projects for insurance, pharmacy, and e-commerce companies, using Python whenever he could. He also worked in a European Union research institute in Italy, testing and enhancing a distributed, Python-based Zope/Plone web application.
He moved to Great Britain in 2007 and first worked with a Scottish start-up, using Twisted Python. Then he worked in the aerospace industry in England using, among other things, the PyQt windowing toolkit, the Enthought application framework, and the NumPy and SciPy libraries. He returned to Hungary in 2012 and rejoined MultiRáció, where he's been working on a Python extension module for OpenOffice/EuroOffice, using NumPy and SciPy again, which allows users to solve nonlinear and stochastic optimization and statistical problems.
Miklós likes to travel, read, and he is interested in science, linguistics, history, politics, the board game of Go, and quite a few other topics. Besides these, he always enjoys a good cup of coffee. However, spending time with his brilliant 11-year-old son, Zsombor, is the most important thing for him.
www.PacktPub.com
Support files, eBooks, discount offers, and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print and bookmark content
On demand and accessible via web browser
Free access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.