Python for Scientists
Kaup valmöguleikar
The third edition of this practical introduction to Python has been thoroughly updated, with all code migrated to Jupyter notebooks. The notebooks are available online with executable versions of all of the book's content (and more). The text starts with a detailed introduction to the basics of the Python language, without assuming any prior knowledge. Building upon each other, the most important Python packages for numerical math (NumPy), symbolic math (SymPy), and plotting (Matplotlib) are introduced, with brand new chapters covering numerical methods (SciPy) and data handling (Pandas).
Further new material includes guidelines for writing efficient Python code and publishing code for other users. Simple and concise code examples, revised for compatibility with Python 3, guide the reader and support the learning process throughout the book. Readers from all of the quantitative sciences, whatever their background, will be able to quickly acquire the skills needed for using Python effectively.
Nánar um bókina
- Cambridge University Press
- 9781009034357
- 9781009014809
- Page Fidelity (PDF)
- 3
- John M. Stewart; Michael Mommert
- English
- 2023-08-17
- 100
- 2
- 2
Kaflar
- Halftitle page
- Title page
- Copyright page
- Contents
- Preface
- 1 Introduction
- 1.1 Python for Scientists
- 1.2 Scientific Software
- 1.3 About This Book
- 1.4 References
- 2 About Python
- 2.1 What Is Python?
- 2.1.1 A Brief History of Python
- 2.1.2 The Zen of Python
- 2.2 Installing Python
- 2.2.1 Anaconda and Conda
- 2.2.2 Pip and PyPI
- 2.3 How Python Works
- 2.4 How to Use Python
- 2.4.1 The Python Interpreter
- 2.4.2 IPython and Jupyter
- 2.4.3 Integrated Development Environments
- 2.4.4 Cloud Environments
- 2.5 Where to Find Help?
- 2.6 References
- 3 Basic Python
- 3.1 Typing Python
- 3.2 Objects and Identifiers
- 3.3 Namespaces and Modules
- 3.4 Numbers
- 3.4.1 Integers
- 3.4.2 Real Numbers
- 3.4.3 Booleans
- 3.4.4 Complex Numbers
- 3.5 Container Objects
- 3.5.1 Lists
- 3.5.2 List Indexing
- 3.5.3 List Slicing
- 3.5.4 List Mutability
- 3.5.5 List Functions
- 3.5.6 Tuples
- 3.5.7 Strings
- 3.5.8 Dictionaries
- 3.5.9 Sets
- 3.6 Python if Statements
- 3.7 Loop Constructs
- 3.7.1 The for Loop
- 3.7.2 The while Loop
- 3.7.3 The continue Statement
- 3.7.4 The break Statement
- 3.7.5 List Comprehensions
- 3.8 Functions
- 3.8.1 Syntax and Scope
- 3.8.2 Positional Arguments
- 3.8.3 Keyword Arguments
- 3.8.4 Arbitrary Number of Positional Arguments
- 3.8.5 Arbitrary Number of Keyword Arguments
- 3.8.6 Anonymous Functions
- 3.9 Python Input/Output
- 3.9.1 Keyboard Input
- 3.9.2 The print() Function
- 3.9.3 File Input/Output
- 3.10 Error Handling
- 3.10.1 Traceback
- 3.10.2 Errors, Exceptions, and Warnings
- 3.11 Introduction to Python Classes
- 3.12 The Structure of Python
- 3.13 A Python Style Guide
- 3.14 References
- 4 NumPy: Numerical Math
- 4.1 Arrays
- 4.1.1 One-Dimensional Arrays
- 4.1.2 Basic Array Arithmetic
- 4.1.3 Two (and More)-Dimensional Arrays
- 4.1.4 Broadcasting
- 4.1.5 Array Manipulations
- 4.2 Working with Arrays
- 4.2.1 Mathematical Functions and Operators
- 4.2.2 Sums and Products
- 4.2.3 Comparing Arrays
- 4.2.4 Advanced Array Indexing
- 4.2.5 Sorting and Searching
- 4.3 Constants
- 4.4 Random Numbers
- 4.5 Simple Statistics
- 4.6 Polynomials
- 4.6.1 Converting Data to Coefficients
- 4.6.2 Converting Coefficients to Data
- 4.6.3 Manipulating Polynomials in Coefficient Form
- 4.7 Linear Algebra
- 4.7.1 Basic Operations on Matrices
- 4.7.2 Matrix Arithmetic
- 4.7.3 Solving Linear Systems of Equations
- 4.8 File Input/Output
- 4.8.1 Text File Input/Output
- 4.8.2 Binary File Input/Output
- 4.9 Special Array Types
- 4.9.1 Masked Arrays
- 4.9.2 Structured Arrays
- 4.10 References
- 5 SciPy: Numerical Methods
- 5.1 Special Functions
- 5.2 Constants
- 5.3 Numerical Integration
- 5.3.1 Integrating over Functions
- 5.3.2 Integrating over Sampled Values
- 5.4 Optimization and Root Search
- 5.4.1 Local Univariate Optimization
- 5.4.2 Local Multivariate Optimization
- 5.4.3 Function Fitting
- 5.4.4 Root Search
- 5.5 Numerical Interpolation
- 5.5.1 Univariate Interpolation
- 5.5.2 Multivariate Interpolation
- 5.6 Linear Algebra
- 5.6.1 Matrix Operations
- 5.7 Statistics
- 5.7.1 Univariate Continuous Probability Distributions
- 5.7.2 Multivariate and Discrete Probability Distributions
- 5.7.3 Correlation Tests
- 5.7.4 Distribution Tests
- 5.8 Ordinary Differential Equations
- 5.8.1 Initial Value Problems
- 5.8.2 Boundary Value Problems
- 5.9 SciKits: A Whole New World
- 5.10 References
- 6 Matplotlib: Plotting
- 6.1 Getting Started: Simple Figures
- 6.1.1 Frontends
- 6.1.2 Backends
- 6.1.3 A Simple Figure
- 6.2 Object-Oriented Matplotlib
- 6.3 Customizing Plots
- 6.3.1 Figure Size
- 6.3.2 Axis Range and Scaling
- 6.3.3 Ticks
- 6.3.4 Grid
- 6.3.5 Legend
- 6.3.6 Transparency
- 6.3.7 Text and Annotations
- 6.3.8 Mathematical Formulae
- 6.3.9 Colors
- 6.4 Cartesian Plots
- 6.4.1 Line Plots
- 6.4.2 Scatter Plots
- 6.4.3 Error Bars
- 6.4.4 Plotting Filled Areas
- 6.4.5 Bar Plots
- 6.5 Polar Plots
- 6.6 Plotting Images
- 6.7 Contour Plots
- 6.8 Compound Figures
- 6.9 Multidimensional Visualization
- 6.9.1 The Reduction to Two Dimensions
- 6.9.2 3D Plots
- 6.10 References
- 7 SymPy: Symbolic Math
- 7.1 Symbols and Functions
- 7.2 Conversions from Python to SymPy and Vice Versa
- 7.3 Matrices and Vectors
- 7.4 Some Elementary Calculus
- 7.4.1 Differentiation
- 7.4.2 Integration
- 7.4.3 Series and Limits
- 7.5 Equality, Symbolic Equality and Simplification
- 7.6 Solving Equations
- 7.6.1 Equations with One Independent Variable
- 7.6.2 Linear Equations with More than One Independent Variable
- 7.6.3 More General Equations
- 7.6.4 Solving Ordinary Differential Equations
- 7.6.5 Solving Partial Differential Equations
- 7.7 Plotting from within SymPy
- 7.8 References
- 8 Pandas: Data Handling
- 8.1 Series
- 8.2 DataFrames
- 8.2.1 Axis Labels and Indexes
- 8.2.2 Accessing Data
- 8.2.3 Modifying Data
- 8.2.4 Dealing with Missing Data
- 8.3 Specific Types of Data
- 8.3.1 Categorical Data
- 8.3.2 Textual Data
- 8.3.3 Dates and Times
- 8.4 Functions
- 8.5 Data Visualization
- 8.6 File Input/Output
- 8.7 Pandas Hints
- 8.8 References
- 9 Performance Python
- 9.1 How to Write Efficient Python Code
- 9.1.1 Measuring performance
- 9.1.2 Optimization Starts before Coding
- 9.1.3 Optimizing Basic Python
- 9.1.4 NumPy
- 9.2 Parallelization
- 9.2.1 Multithreading
- 9.2.2 Multiprocessing
- 9.3 What Else?
- 9.4 References
- 10 Software Development Tools
- 10.1 Version Control
- 10.1.1. git
- 10.2 Create Your Own Python Module
- 10.3 Publish Your Code
- 10.3.1 GitHub
- 10.3.2 Python Package Index
- 10.4 References
- Index