<!--[if gte mso 9]><xml> </xml><![endif]--> <p style="margin:0px;"></p> <p style="margin:0px;">Foreword xix</p> <p style="margin:0px;">Preface xxi</p> <p style="margin:0px;">Acknowledgments xxvii</p> <p style="margin:0px;">About the Author xxxi</p> <p style="margin:0px;"></p> <p style="margin:0px;"> </p> <p style="margin:0px;"></p> <p style="margin:0px;">Part I: Introduction 1</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 1: Pandas DataFrame Basics 3</p> <p style="margin:0px;"></p> <p style="margin:0px;">1.1 Introduction 3</p> <p style="margin:0px;">1.2 Loading Your First Data Set 4</p> <p style="margin:0px;">1.3 Looking at Columns, Rows, and Cells 7</p> <p style="margin:0px;">1.4 Grouped and Aggregated Calculations 18</p> <p style="margin:0px;">1.5 Basic Plot 23</p> <p style="margin:0px;">1.6 Conclusion 24</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 2: Pandas Data Structures 25</p> <p style="margin:0px;">2.1 Introduction 25</p> <p style="margin:0px;">2.2 Creating Your Own Data 26</p> <p style="margin:0px;">2.3 The Series 28</p> <p style="margin:0px;">2.4 The DataFrame 36</p> <p style="margin:0px;">2.5 Making Changes to Series and DataFrames 38</p> <p style="margin:0px;">2.6 Exporting and Importing Data 43</p> <p style="margin:0px;">2.7 Conclusion 47</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 3: Introduction to Plotting 49</p> <p style="margin:0px;">3.1 Introduction 49</p> <p style="margin:0px;">3.2 Matplotlib 51</p> <p style="margin:0px;">3.3 Statistical Graphics Using matplotlib 56</p> <p style="margin:0px;">3.4 Seaborn 61</p> <p style="margin:0px;">3.5 Pandas Objects 83</p> <p style="margin:0px;">3.6 Seaborn Themes and Styles 86</p> <p style="margin:0px;">3.7 Conclusion 90</p> <p style="margin:0px;"> </p> <p style="margin:0px;"></p> <p style="margin:0px;">Part II: Data Manipulation 91</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 4: Data Assembly 93</p> <p style="margin:0px;"></p> <p style="margin:0px;">4.1 Introduction 93</p> <p style="margin:0px;">4.2 Tidy Data 93</p> <p style="margin:0px;">4.3 Concatenation 94</p> <p style="margin:0px;">4.4 Merging Multiple Data Sets 102</p> <p style="margin:0px;">4.5 Conclusion 107</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 5: Missing Data 109</p> <p style="margin:0px;">5.1 Introduction 109</p> <p style="margin:0px;">5.2 What Is a NaN Value? 109</p> <p style="margin:0px;">5.3 Where Do Missing Values Come From? 111</p> <p style="margin:0px;">5.4 Working with Missing Data 116</p> <p style="margin:0px;">5.5 Conclusion 121</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 6: Tidy Data 123</p> <p style="margin:0px;">6.1 Introduction 123</p> <p style="margin:0px;">6.2 Columns Contain Values, Not Variables 124</p> <p style="margin:0px;">6.3 Columns Contain Multiple Variables 128</p> <p style="margin:0px;">6.4 Variables in Both Rows and Columns 133</p> <p style="margin:0px;">6.5 Multiple Observational Units in a Table (Normalization) 134</p> <p style="margin:0px;">6.6 Observational Units Across Multiple Tables 137</p> <p style="margin:0px;">6.7 Conclusion 141</p> <p style="margin:0px;"> </p> <p style="margin:0px;"></p> <p style="margin:0px;">Part III: Data Munging 143</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 7: Data Types 145</p> <p style="margin:0px;"></p> <p style="margin:0px;">7.1 Introduction 145</p> <p style="margin:0px;">7.2 Data Types 145</p> <p style="margin:0px;">7.3 Converting Types 146</p> <p style="margin:0px;">7.4 Categorical Data 152</p> <p style="margin:0px;">7.5 Conclusion 153</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 8: Strings and Text Data 155</p> <p style="margin:0px;">8.1 Introduction 155</p> <p style="margin:0px;">8.2 Strings 155</p> <p style="margin:0px;">8.3 String Methods 158</p> <p style="margin:0px;">8.4 More String Methods 160</p> <p style="margin:0px;">8.5 String Formatting 161</p> <p style="margin:0px;">8.6 Regular Expressions (RegEx) 164</p> <p style="margin:0px;">8.7 The regex Library 170</p> <p style="margin:0px;">8.8 Conclusion 170</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 9: Apply 171</p> <p style="margin:0px;">9.1 Introduction 171</p> <p style="margin:0px;">9.2 Functions 171</p> <p style="margin:0px;">9.3 Apply (Basics) 172</p> <p style="margin:0px;">9.4 Apply (More Advanced) 177</p> <p style="margin:0px;">9.5 Vectorized Functions 182</p> <p style="margin:0px;">9.6 Lambda Functions 185</p> <p style="margin:0px;">9.7 Conclusion 187</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 10: Groupby Operations: Split–Apply–Combine 189</p> <p style="margin:0px;">10.1 Introduction 189</p> <p style="margin:0px;">10.2 Aggregate 190</p> <p style="margin:0px;">10.3 Transform 197</p> <p style="margin:0px;">10.4 Filter 201</p> <p style="margin:0px;">10.5 The pandas.core.groupby.DataFrameGroupBy Object 202</p> <p style="margin:0px;">10.6 Working with a MultiIndex 207</p> <p style="margin:0px;">10.7 Conclusion 211</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 11: The datetime Data Type 213</p> <p style="margin:0px;">11.1 Introduction 213</p> <p style="margin:0px;">11.2 Python’s datetime Object 213</p> <p style="margin:0px;">11.3 Converting to datetime 214</p> <p style="margin:0px;">11.4 Loading Data That Include Dates 217</p> <p style="margin:0px;">11.5 Extracting Date Components 217</p> <p style="margin:0px;">11.6 Date Calculations and Timedeltas 220</p> <p style="margin:0px;">11.7 Datetime Methods 221</p> <p style="margin:0px;">11.8 Getting Stock Data 224</p> <p style="margin:0px;">11.9 Subsetting Data Based on Dates 225</p> <p style="margin:0px;">11.10 Date Ranges 227</p> <p style="margin:0px;">11.11 Shifting Values 230</p> <p style="margin:0px;">11.12 Resampling 237</p> <p style="margin:0px;">11.13 Time Zones 238</p> <p style="margin:0px;">11.14 Conclusion 240</p> <p style="margin:0px;"> </p> <p style="margin:0px;"></p> <p style="margin:0px;">Part IV: Data Modeling 241</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 12: Linear Models 243</p> <p style="margin:0px;"></p> <p style="margin:0px;">12.1 Introduction 243</p> <p style="margin:0px;">12.2 Simple Linear Regression 243</p> <p style="margin:0px;">12.3 Multiple Regression 247</p> <p style="margin:0px;">12.4 Keeping Index Labels From sklearn 251</p> <p style="margin:0px;">12.5 Conclusion 252</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 13: Generalized Linear Models 253</p> <p style="margin:0px;">13.1 Introduction 253</p> <p style="margin:0px;">13.2 Logistic Regression 253</p> <p style="margin:0px;">13.3 Poisson Regression 257</p> <p style="margin:0px;">13.4 More Generalized Linear Models 260</p> <p style="margin:0px;">13.5 Survival Analysis 260</p> <p style="margin:0px;">13.6 Conclusion 264</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 14: Model Diagnostics 265</p> <p style="margin:0px;">14.1 Introduction 265</p> <p style="margin:0px;">14.2 Residuals 265</p> <p style="margin:0px;">14.3 Comparing Multiple Models 270</p> <p style="margin:0px;">14.4 k-Fold Cross-Validation 275</p> <p style="margin:0px;">14.5 Conclusion 278</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 15: Regularization 279</p> <p style="margin:0px;">15.1 Introduction 279</p> <p style="margin:0px;">15.2 Why Regularize? 279</p> <p style="margin:0px;">15.3 LASSO Regression 281</p> <p style="margin:0px;">15.4 Ridge Regression 283</p> <p style="margin:0px;">15.5 Elastic Net 285</p> <p style="margin:0px;">15.6 Cross-Validation 287</p> <p style="margin:0px;">15.7 Conclusion 289</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 16: Clustering 291</p> <p style="margin:0px;">16.1 Introduction 291</p> <p style="margin:0px;">16.2 k-Means 291</p> <p style="margin:0px;">16.3 Hierarchical Clustering 297</p> <p style="margin:0px;">16.4 Conclusion 301</p> <p style="margin:0px;"> </p> <p style="margin:0px;"></p> <p style="margin:0px;">Part V: Conclusion 303</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 17: Life Outside of Pandas 305</p> <p style="margin:0px;"></p> <p style="margin:0px;">17.1 The (Scientific) Computing Stack 305</p> <p style="margin:0px;">17.2 Performance 306</p> <p style="margin:0px;">17.3 Going Bigger and Faster 307</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Chapter 18: Toward a Self-Directed Learner 309</p> <p style="margin:0px;">18.1 It’s Dangerous to Go Alone! 309</p> <p style="margin:0px;">18.2 Local Meetups 309</p> <p style="margin:0px;">18.3 Conferences 309</p> <p style="margin:0px;">18.4 The Internet 310</p> <p style="margin:0px;">18.5 Podcasts 310</p> <p style="margin:0px;">18.6 Conclusion 311</p> <p style="margin:0px;"> </p> <p style="margin:0px;"></p> <p style="margin:0px;">Part VI: Appendixes 313</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix A: Installation 315</p> <p style="margin:0px;"></p> <p style="margin:0px;">A.1 Installing Anaconda 315</p> <p style="margin:0px;">A.2 Uninstall Anaconda 316</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix B: Command Line 317</p> <p style="margin:0px;">B.1 Installation 317</p> <p style="margin:0px;">B.2 Basics 318</p> <p style="margin:0px;"> </p> <p style="margin:0px;"></p> <p style="margin:0px;">Appendix C: Project Templates 319</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix D: Using Python 321</p> <p style="margin:0px;"></p> <p style="margin:0px;">D.1 Command Line and Text Editor 321</p> <p style="margin:0px;">D.2 Python and IPython 322</p> <p style="margin:0px;">D.3 Jupyter 322</p> <p style="margin:0px;">D.4 Integrated Development Environments (IDEs) 322</p> <p style="margin:0px;"> </p> <p style="margin:0px;"></p> <p style="margin:0px;">Appendix E: Working Directories 325</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix F: Environments 327</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix G: Install Packages 329</p> <p style="margin:0px;"></p> <p style="margin:0px;">G.1 Updating Packages 330</p> <p style="margin:0px;"> </p> <p style="margin:0px;"></p> <p style="margin:0px;">Appendix H: Importing Libraries 331</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix I: Lists 333</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix J: Tuples 335</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix K: Dictionaries 337</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix L: Slicing Values 339</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix M: Loops 341</p> <p style="margin:0px;"></p> <p style="margin:0px;"> </p> <p style="margin:0px;"></p> <p style="margin:0px;">Appendix N: Comprehensions 343</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix O: Functions 345</p> <p style="margin:0px;"></p> <p style="margin:0px;">O.1 Default Parameters 347</p> <p style="margin:0px;">O.2 Arbitrary Parameters 347</p> <p style="margin:0px;"> </p> <p style="margin:0px;"></p> <p style="margin:0px;">Appendix P: Ranges and Generators 349</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix Q: Multiple Assignment 351</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix R: numpy ndarray 353</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix S: Classes 355</p> <p style="margin:0px;"> </p> <p style="margin:0px;">Appendix T: Odo: The Shapeshifter 357</p> <p style="margin:0px;"></p> <p style="margin:0px;"> </p> <p style="margin:0px;">Index 359</p> <!--[if gte mso 9]><xml> Normal 0 false false false EN-US X-NONE X-NONE </xml><![endif]--> <!--[if gte mso 9]><xml> </xml><![endif]--> <!--[if gte mso 10]> <![endif]-->