Author(s): Christian Mayer
Publisher: no starch press
Year: 2020
Language: English
Pages: 278
Title Page
Copyright Page
Dedication
About the Author
About the Technical Reviewer
Brief Contents
Contents in Detail
Acknowledgments
Introduction
Python One-Liner Example
A Note on Readability
Who Is This Book For?
What Will You Learn?
Online Resources
1 Python Refresher
Basic Data Structures
Container Data Structures
Control Flow
Functions
Lambdas
Summary
2 Python Tricks
Using List Comprehension to Find Top Earners
Using List Comprehension to Find Words with High Information Value
Reading a File
Using Lambda and Map Functions
Using Slicing to Extract Matching Substring Environments
Combining List Comprehension and Slicing
Using Slice Assignment to Correct Corrupted Lists
Analyzing Cardiac Health Data with List Concatenation
Using Generator Expressions to Find Companies That Pay Below Minimum Wage
Formatting Databases with the zip() Function
Summary
3 Data Science
Basic Two-Dimensional Array Arithmetic
Working with NumPy Arrays: Slicing, Broadcasting, and Array Types
Conditional Array Search, Filtering, and Broadcasting to Detect Outliers
Boolean Indexing to Filter Two-Dimensional Arrays
Broadcasting, Slice Assignment, and Reshaping to Clean Every i-th Array Element
When to Use the sort() Function and When to Use the argsort() Function in NumPy
How to Use Lambda Functions and Boolean Indexing to Filter Arrays
How to Create Advanced Array Filters with Statistics, Math, and Logic
Simple Association Analysis: People Who Bought X Also Bought Y
Intermediate Association Analysis to Find Bestseller Bundles
Summary
4 Machine Learning
The Basics of Supervised Machine Learning
Linear Regression
Logistic Regression in One Line
K-Means Clustering in One Line
K-Nearest Neighbors in One Line
Neural Network Analysis in One Line
Decision-Tree Learning in One Line
Get Row with Minimal Variance in One Line
Basic Statistics in One Line
Classification with Support-Vector Machines in One Line
Classification with Random Forests in One Line
Summary
5 Regular Expressions
Finding Basic Textual Patterns in Strings
Writing Your First Web Scraper with Regular Expressions
Analyzing Hyperlinks of HTML Documents
Extracting Dollars from a String
Finding Nonsecure HTTP URLs
Validating the Time Format of User Input, Part 1
Validating Time Format of User Input, Part 2
Duplicate Detection in Strings
Detecting Word Repetitions
Modifying Regex Patterns in a Multiline String
Summary
6 Algorithms
Finding Anagrams with Lambda Functions and Sorting
Finding Palindromes with Lambda Functions and Negative Slicing
Counting Permutations with Recursive Factorial Functions
Finding the Levenshtein Distance
Calculating the Powerset by Using Functional Programming
Caesar’s Cipher Encryption Using Advanced Indexing and List Comprehension
Finding Prime Numbers with the Sieve of Eratosthenes
Calculating the Fibonacci Series with the reduce() Function
A Recursive Binary Search Algorithm
A Recursive Quicksort Algorithm
Summary
Afterword
Index