Python Basics
Subtitle: With Illustrations from the Financial Markets
Publisher: QuantInsti Quantitative Learning Pvt. Ltd.
Published: 2019
Language: eng
Table of contents: title: Contents; title: 1 Introduction
pagenum: 1 |; title: 1.1 What is Python?
pagenum: 1 |; title: 1.2 Where is Python used?
pagenum: 2 |; title: 1.3 Why Python?
pagenum: 2 |; title: 1.4 History of Python
pagenum: 6 |; title: 1.5 Python 3 versus Python 2
pagenum: 7 |; title: 1.6 Key Takeaways
pagenum: 10 |; title: 2 Getting Started with Python
pagenum: 11 |; title: 2.1 Python as a Calculator
pagenum: 11 |; title: 2.1.1 Floating Point Expressions
pagenum: 14 |; title: 2.2 Python Basics
pagenum: 17 |; title: 2.2.1 Literal Constants
pagenum: 17 |; title: 2.2.2 Numbers
pagenum: 18 |; title: 2.2.3 Strings
pagenum: 18 |; title: 2.2.4 Comments
pagenum: 19 |; title: 2.2.5 print() function
pagenum: 20 |; title: 2.2.6 format() function
pagenum: 22 |; title: 2.2.7 Escape Sequence
pagenum: 23 |; title: 2.2.8 Indentation
pagenum: 24 |; title: 2.3 Key Takeaways
pagenum: 25 |; title: 3 Variables and Data Types in Python
pagenum: 27 |; title: 3.1 Variables
pagenum: 27 |; title: 3.1.1 Variable Declaration and Assignment
pagenum: 27 |; title: 3.1.2 Variable Naming Conventions
pagenum: 28 |; title: 3.2 Data Types
pagenum: 31 |; title: 3.2.1 Integer
pagenum: 31 |; title: 3.2.2 Float
pagenum: 32 |; title: 3.2.3 Boolean
pagenum: 34 |; title: 3.2.4 String
pagenum: 35 |; title: 3.2.5 Operations on String
pagenum: 38 |; title: 3.2.6 type() function
pagenum: 41 |; title: 3.3 Type Conversion
pagenum: 42 |; title: 3.4 Key Takeaways
pagenum: 45 |; title: 4 Modules, Packages and Libraries
pagenum: 47 |; title: 4.1 Standard Modules
pagenum: 50 |; title: 4.2 Packages
pagenum: 52 |; title: 4.3 Installation of External Libraries
pagenum: 53 |; title: 4.3.1 Installing pip
pagenum: 54 |; title: 4.3.2 Installing Libraries
pagenum: 54 |; title: 4.4 Importing modules
pagenum: 56 |; title: 4.4.1 import statement
pagenum: 56 |; title: 4.4.2 Selective imports
pagenum: 57 |; title: 4.4.3 The Module Search Path
pagenum: 59 |; title: 4.5 dir()function
pagenum: 61 |; title: 4.6 Key Takeaways
pagenum: 63 |; title: 5 Data Structures
pagenum: 65 |; title: 5.1 Indexing and Slicing
pagenum: 65 |; title: 5.2 Array
pagenum: 67 |; title: 5.2.1 Visualizing an Array
pagenum: 67 |; title: 5.2.2 Accessing Array Element
pagenum: 68 |; title: 5.2.3 Manipulating Arrays
pagenum: 68 |; title: 5.3 Tuples
pagenum: 70 |; title: 5.3.1 Accessing tuple elements
pagenum: 71 |; title: 5.3.2 Immutability
pagenum: 72 |; title: 5.3.3 Concatenating Tuples
pagenum: 72 |; title: 5.3.4 Unpacking Tuples
pagenum: 73 |; title: 5.3.5 Tuple methods
pagenum: 73 |; title: 5.4 Lists
pagenum: 74 |; title: 5.4.1 Accessing List Items
pagenum: 75 |; title: 5.4.2 Updating Lists
pagenum: 75 |; title: 5.4.3 List Manipulation
pagenum: 77 |; title: 5.4.4 Stacks and Queues
pagenum: 80 |; title: 5.5 Dictionaries
pagenum: 82 |; title: 5.5.1 Creating and accessing dictionaries
pagenum: 82 |; title: 5.5.2 Altering dictionaries
pagenum: 85 |; title: 5.5.3 Dictionary Methods
pagenum: 86 |; title: 5.6 Sets
pagenum: 88 |; title: 5.7 Key Takeaways
pagenum: 92 |; title: 6 Keywords & Operators
pagenum: 95 |; title: 6.1 Python Keywords
pagenum: 95 |; title: 6.2 Operators
pagenum: 106 |; title: 6.2.1 Arithmetic operators
pagenum: 106 |; title: 6.2.2 Comparison operators
pagenum: 107 |; title: 6.2.3 Logical operators
pagenum: 109 |; title: 6.2.4 Bitwise operator
pagenum: 110 |; title: 6.2.5 Assignment operators
pagenum: 114 |; title: 6.2.6 Membership operators
pagenum: 118 |; title: 6.2.7 Identity operators
pagenum: 118 |; title: 6.2.8 Operator Precedence
pagenum: 119 |; title: 6.3 Key Takeaways
pagenum: 121 |; title: 7 Control Flow Statements
pagenum: 123 |; title: 7.1 Conditional Statements
pagenum: 123 |; title: 7.1.1 The if statement
pagenum: 123 |; title: 7.1.2 The elif clause
pagenum: 125 |; title: 7.1.3 The else clause
pagenum: 125 |; title: 7.2 Loops
pagenum: 126 |; title: 7.2.1 The while statement
pagenum: 126 |; title: 7.2.2 The for statement
pagenum: 128 |; title: 7.2.3 The range() function
pagenum: 128 |; title: 7.2.4 Looping through lists
pagenum: 130 |; title: 7.2.5 Looping through strings
pagenum: 131 |; title: 7.2.6 Looping through dictionaries
pagenum: 131 |; title: 7.2.7 Nested loops
pagenum: 133 |; title: 7.3 Loop control statements
pagenum: 134 |; title: 7.3.1 The break keyword
pagenum: 134 |; title: 7.3.2 The continue keyword
pagenum: 135 |; title: 7.3.3 The pass keyword
pagenum: 136 |; title: 7.4 List comprehensions
pagenum: 137 |; title: 7.5 Key Takeaways
pagenum: 140 |; title: 8 Iterators & Generators
pagenum: 143 |; title: 8.1 Iterators
pagenum: 143 |; title: 8.1.1 Iterables
pagenum: 143 |; title: 8.1.2 enumerate() function
pagenum: 145 |; title: 8.1.3 The zip()function
pagenum: 146 |; title: 8.1.4 Creating a custom iterator
pagenum: 147 |; title: 8.2 Generators
pagenum: 149 |; title: 8.3 Key Takeaways
pagenum: 151 |; title: 9 Functions in Python
pagenum: 153 |; title: 9.1 Recapping built-in functions
pagenum: 154 |; title: 9.2 User defined functions
pagenum: 155 |; title: 9.2.1 Functions with a single argument
pagenum: 156 |; title: 9.2.2 Functions with multiple arguments and a return statement
pagenum: 157 |; title: 9.2.3 Functions with default arguments
pagenum: 159 |; title: 9.2.4 Functions with variable length arguments
pagenum: 160 |; title: 9.2.5 DocStrings
pagenum: 162 |; title: 9.2.6 Nested functions and non-local variable
pagenum: 164 |; title: 9.3 Variable Namespace and Scope
pagenum: 166 |; title: 9.3.1 Names in the Python world
pagenum: 167 |; title: 9.3.2 Namespace
pagenum: 168 |; title: 9.3.3 Scopes
pagenum: 169 |; title: 9.4 Lambda functions
pagenum: 174 |; title: 9.4.1 map() Function
pagenum: 175 |; title: 9.4.2 filter() Function
pagenum: 176 |; title: 9.4.3 zip() Function 177; title: 9.5 Key Takeaways
pagenum: 179 |; title: 10 NumPy Module
pagenum: 181 |; title: 10.1 NumPy Arrays
pagenum: 182 |; title: 10.1.1 N-dimensional arrays
pagenum: 185 |; title: 10.2 Array creation using built-in functions
pagenum: 186 |; title: 10.3 Random Sampling in NumPy
pagenum: 188 |; title: 10.4 Array Attributes and Methods
pagenum: 192 |; title: 10.5 Array Manipulation
pagenum: 198 |; title: 10.6 Array Indexing and Iterating
pagenum: 203 |; title: 10.6.1 Indexing and Subsetting
pagenum: 203 |; title: 10.6.2 Boolean Indexing
pagenum: 205 |; title: 10.6.3 Iterating Over Arrays
pagenum: 210 |; title: 10.7 Key Takeaways
pagenum: 212 |; title: 11 Pandas Module
pagenum: 215 |; title: 11.1 Pandas Installation
pagenum: 215 |; title: 11.1.1 Installing with pip
pagenum: 216 |; title: 11.1.2 Installing with Conda environments
pagenum: 216 |; title: 11.1.3 Testing Pandas installation
pagenum: 216 |; title: 11.2 What problem does Pandas solve?
pagenum: 216 |; title: 11.3 Pandas Series
pagenum: 217 |; title: 11.3.1 Simple operations with Pandas Series
pagenum: 219 |; title: 11.4 Pandas DataFrame
pagenum: 223 |; title: 11.5 Importing data in Pandas
pagenum: 228 |; title: 11.5.1 Importing data from CSV file
pagenum: 228 |; title: 11.5.2 Customizing pandas import
pagenum: 228 |; title: 11.5.3 Importing data from Excel files
pagenum: 229 |; title: 11.6 Indexing and Subsetting
pagenum: 229 |; title: 11.6.1 Selecting a single column
pagenum: 230 |; title: 11.6.2 Selecting multiple columns
pagenum: 230 |; title: 11.6.3 Selecting rows via []
pagenum: 231 |; title: 11.6.4 Selecting via .loc[] (By label)
pagenum: 232 |; title: 11.6.5 Selecting via .iloc[] (By position)
pagenum: 233 |; title: 11.6.6 Boolean indexing
pagenum: 234 |; title: 11.7 Manipulating a DataFrame
pagenum: 235 |; title: 11.7.1 Transpose using .T
pagenum: 235 |; title: 11.7.2 The .sort_index() method
pagenum: 236 |; title: 11.7.3 The .sort_values() method
pagenum: 236 |; title: 11.7.4 The .reindex() function
pagenum: 237 |; title: 11.7.5 Adding a new column
pagenum: 238 |; title: 11.7.6 Delete an existing column
pagenum: 239 |; title: 11.7.7 The .at[] (By label)
pagenum: 241 |; title: 11.7.8 The .iat[] (By position)
pagenum: 242 |; title: 11.7.9 Conditional updating of values
pagenum: 243 |; title: 11.7.10 The .dropna() method
pagenum: 244 |; title: 11.7.11 The .fillna() method
pagenum: 246 |; title: 11.7.12 The .apply() method
pagenum: 247 |; title: 11.7.13 The .shift() function
pagenum: 248 |; title: 11.8 Statistical Exploratory data analysis
pagenum: 250 |; title: 11.8.1 The info() function
pagenum: 250 |; title: 11.8.2 The describe() function
pagenum: 251 |; title: 11.8.3 The value_counts() function
pagenum: 252 |; title: 11.8.4 The mean() function
pagenum: 252 |; title: 11.8.5 The std() function
pagenum: 253 |; title: 11.9 Filtering Pandas DataFrame
pagenum: 253 |; title: 11.10Iterating Pandas DataFrame
pagenum: 255 |; title: 11.11Merge, Append and Concat Pandas DataFrame
pagenum: 256 |; title: 11.12TimeSeries in Pandas
pagenum: 259 |; title: 11.12.1 Indexing Pandas TimeSeries
pagenum: .259 |; title: 11.12.2 Resampling Pandas TimeSeries
pagenum: 262 |; title: 11.12.3 Manipulating TimeSeries
pagenum: 263 |; title: 11.13Key Takeaways
pagenum: 265 |; title: 12 Data Visualization with Matplotlib
pagenum: 267 |; title: 12.1 Basic Concepts
pagenum: 268 |; title: 12.1.1 Axes
pagenum: 269 |; title: 12.1.2 Axes method v/s pyplot
pagenum: 272 |; title: 12.1.3 Multiple Axes
pagenum: 273 |; title: 12.2 Plotting
pagenum: 275 |; title: 12.2.1 Line Plot
pagenum: 276 |; title: 12.2.2 Scatter Plot
pagenum: 289 |; title: 12.2.3 Histogram Plots
pagenum: 294 |; title: 12.3 Customization
pagenum: 300 |; title: 12.4 Key Takeaways
pagenum: 313 |