Copyright; Table of Contents; Preface; What Is Data Science?; Who Is This Book For?; Why Python?; Python 2 Versus Python 3; Outline of This Book; Using Code Examples; Installation Considerations; Conventions Used in This Book; O''Reilly Safari; How to Contact Us; Chapter 1. IPython: Beyond Normal Python; Shell or Notebook?; Launching the IPython Shell; Launching the Jupyter Notebook; Help and Documentation in IPython; Accessing Documentation with?; Accessing Source Code with??; Exploring Modules with Tab Completion; Keyboard Shortcuts in the IPython Shell; Navigation Shortcuts.
Text Entry Shortcuts; Command History Shortcuts; Miscellaneous Shortcuts; IPython Magic Commands; Pasting Code Blocks: %paste and %cpaste; Running External Code: %run; Timing Code Execution: %timeit; Help on Magic Functions:?, %magic, and %lsmagic; Input and Output History; IPython''s In and Out Objects; Underscore Shortcuts and Previous Outputs; Suppressing Output; Related Magic Commands; IPython and Shell Commands; Quick Introduction to the Shell; Shell Commands in IPython; Passing Values to and from the Shell; Shell-Related Magic Commands; Errors and Debugging; Controlling Exceptions: %xmode.
Debugging: When Reading Tracebacks Is Not Enough; Profiling and Timing Code; Timing Code Snippets: %timeit and %time; Profiling Full Scripts: %prun; Line-by-Line Profiling with %lprun; Profiling Memory Use: %memit and %mprun; More IPython Resources; Web Resources; Books; Chapter 2. Introduction to NumPy; Understanding Data Types in Python; A Python Integer Is More Than Just an Integer; A Python List Is More Than Just a List; Fixed-Type Arrays in Python; Creating Arrays from Python Lists; Creating Arrays from Scratch; NumPy Standard Data Types; The Basics of NumPy Arrays; NumPy Array Attributes.
Array Indexing: Accessing Single Elements; Array Slicing: Accessing Subarrays; Reshaping of Arrays; Array Concatenation and Splitting; Computation on NumPy Arrays: Universal Functions; The Slowness of Loops; Introducing UFuncs; Exploring NumPy''s UFuncs; Advanced Ufunc Features; Ufuncs: Learning More; Aggregations: Min, Max, and Everything in Between; Summing the Values in an Array; Minimum and Maximum; Example: What Is the Average Height of US Presidents?; Computation on Arrays: Broadcasting; Introducing Broadcasting; Rules of Broadcasting; Broadcasting in Practice.
Comparisons, Masks, and Boolean Logic; Example: Counting Rainy Days; Comparison Operators as ufuncs; Working with Boolean Arrays; Boolean Arrays as Masks; Fancy Indexing; Exploring Fancy Indexing; Combined Indexing; Example: Selecting Random Points; Modifying Values with Fancy Indexing; Example: Binning Data; Sorting Arrays; Fast Sorting in NumPy: np.sort and np.argsort; Partial Sorts: Partitioning; Example: k-Nearest Neighbors; Structured Data: NumPy''s Structured Arrays; Creating Structured Arrays; More Advanced Compound Types; RecordArrays: Structured Arrays with a Twist; On to Pandas.