Look at Python from a data science point of view and learn proven techniques for data visualization as used in making critical business decisions. Starting with an introduction to data science with Python, you will take a closer look at the Python environment and get acquainted with editors such as Jupyter Notebook and Spyder. After going through a primer on Python programming, you will grasp fundamental Python programming techniques used in data science. Moving on to data visualization, you will see how it caters to modern business needs and forms a key factor in decision-making. You will also take a look at some popular data visualization libraries in Python. Shifting focus to data structures, you will learn the various aspects of data structures from a data science perspective. You will then work with file I/O and regular expressions in Python, followed by gathering and cleaning data. Moving on to exploring and analyzing data, you will look at advanced data structures in Python. Then, you will take a deep dive into data visualization techniques, going through a number of plotting systems in Python. In conclusion, you will complete a detailed case study, where you'll get a chance to revisit the concepts you've covered so far. What You Will Learn Use Python programming techniques for data science Master data collections in Python Create engaging visualizations for BI systems Deploy effective strategies for gathering and cleaning data Integrate the Seaborn and Matplotlib plotting systems Who This Book Is For Developers with basic Python programming knowledge looking to adopt key strategies for data analysis and visualizations using Python.--Provided by publisher Table of Contents 5 About the Author 13 About the Technical Reviewers 14 Introduction 16 Chapter 1: Introduction to Data Science with Python 20 The Stages of Data Science 20 Why Python? 21 Basic Features of Python 22 Python Learning Resources 23 Python Environment and Editors 25 Portable Python Editors (No Installation Required) 25 Azure Notebooks 27 Offline and Desktop Python Editors 32 The Basics of Python Programming 32 Basic Syntax 33 Lines and Indentation 34 Multiline Statements 35 Quotation Marks in Python 36 Multiple Statements on a Single Line 37 Read Data from Users 37 Declaring Variables and Assigning Values 38 Multiple Assigns 39 Variable Names and Keywords 40 Statements and Expressions 40 Basic Operators in Python 41 Arithmetic Operators 41 Relational Operators 42 Assign Operators 42 Logical Operators 43 Python Comments 44 Formatting Strings 44 Conversion Types 45 The Replacement Field, {} 46 The Date and Time Module 47 Time Module Methods 48 Python Calendar Module 49 Fundamental Python Programming Techniques 51 Selection Statements 51 Iteration Statements 54 The Use of Break, Continues, and Pass Statements 58 try and except 60 String Processing 61 String Special Operators 61 String Slicing and Concatenation 63 String Conversions and Formatting Symbols 64 Loop Through String 65 Python String Functions and Methods 68 The in Operator 71 Parsing and Extracting Strings 72 Tabular Data and Data Formats 73 Python Pandas Data Science Library 74 A Pandas Series 75 A Pandas Data Frame 76 A Pandas Panels 78 Python Lambdas and the Numpy Library 79 The map() Function 80 The filter() Function 81 The reduce () Function 81 Python Numpy Package 82 Data Cleaning and Manipulation Techniques 83 Abstraction of the Series and Data Frame 83 Running Basic Inferential Analyses 88 Summary 93 Exercises and Answers 93 Chapter 2: The Importance of Data Visualization in Business Intelligence 103 Shifting from Input to Output 104 Why Is Data Visualization Important? 104 Why Do Modern Businesses Need Data Visualization? 105 The Future of Data Visualization 106 How Data Visualization Is Used for Business Decision-Making 107 Faster Responses 107 Simplicity 108 Easier Pattern Visualization 108 Team Involvement 108 Unify Interpretation 108 Introducing Data Visualization Techniques 110 Loading Libraries 111 Popular Libraries for Data Visualization in Python 112 Matplotlib 113 Seaborn 117 Plotly 123 Geoplotlib 126 Pandas 126 Introducing Plots in Python 127 Summary 134 Exercises and Answers 135 Chapter 3: Data Collection Structures 143 Lists 143 Creating Lists 144 Accessing Values in Lists 144 Adding and Updating Lists 145 Deleting List Elements 146 Basic List Operations 147 Indexing, Slicing, and Matrices 148 Built-in List Functions and Methods 148 List Functions 149 List Methods 150 List Sorting and Traversing 151 Lists and Strings 152 Parsing Lines 153 Aliasing 154 Dictionaries 155 Creating Dictionaries 156 Updating and Accessing Values in Dictionaries 157 Deleting Dictionary Elements 159 Built-in Dictionary Functions 159 Built-in Dictionary Methods 161 Tuples 163 Creating Tuples 164 Concatenating Tuples 166 Accessing Values in Tuples 166 Basic Tuples Operations 168 Series 169 Creating a Series with index 169 Creating a Series from a Dictionary 172 Creating a Series from a Scalar Value 173 Vectorized Operations and Label Alignment with Series 174 Name Attribute 175 Data Frames 176 Creating Data Frames from a Dict of Series or Dicts 176 Creating Data Frames from a Dict of Ndarrays/Lists 178 Creating Data Frames from a Structured or Record Array 179 Creating Data Frames from a List of Dicts 179 Creating Data Frames from a Dict of Tuples 180 Selecting, Adding, and Deleting Data Frame Columns 181 Assigning New Columns in Method Chains 183 Indexing and Selecting Data Frames 184 Transposing a Data Frame 188 Data Frame Interoperability with Numpy Functions 189 Panels 190 Creating a Panel from a 3D Ndarray 190 Creating a Panel from a Dict of Data Frame Objects 191 Selecting, Adding, and Deleting Items 193 Summary 194 Exercises and Answers 195 Chapter 4: File I/O Processing and Regular Expressions 200 File I/O Processing 200 Data Input and Output 200 Opening and Closing Files 201 File Object Attributes 202 Reading and Writing to Files 203 Directories in Python 204 Regular Expressions 205 Regular Expression Patterns 205 Special Character Classes 214 Repetition Classes 215 Alternatives 215 Anchors 216 Summary 218 Exercises and Answer 219 Chapter 5: Data Gathering and Cleaning 222 Cleaning Data 223 Checking for Missing Values 224 Handling the Missing Values 226 Reading and Cleaning CSV Data 229 Merging and Integrating Data 235 Reading Data from the JSON Format 240 Reading Data from the HTML Format 243 Reading Data from the XML Format 250 Summary 252 Exercises and Answers 253 Chapter 6: Data Exploring and Analysis 259 Series Data Structures 259 Creating a Series 260 Accessing Data from a Series with a Position 262 Exploring and Analyzing a Series 264 Operations on a Series 267 Data Frame Data Structures 270 Creating a Data Frame 271 Updating and Accessing a Data Frame’s Column Selection 274 Column Addition 275 Column Deletion 276 Row Selection 280 Row Addition 282 Row Deletion 283 Exploring and Analyzing a Data Frame 283 Panel Data Structures 289 Creating a Panel 289 Accessing Data from a Panel with a Position 290 Exploring and Analyzing a Panel 291 Data Analysis 293 Statistical Analysis 293 Data Grouping 298 Iterating Through Groups 299 Aggregations 300 Transformations 301 Filtration 302 Summary 303 Exercises and Answers 304 Chapter 7: Data Visualization 309 Direct Plotting 310 Line Plot 311 Bar Plot 314 Pie Chart 316 Box Plot 317 Histogram Plot 319 Scatter Plot 319 Seaborn Plotting System 320 Strip Plot 321 Box Plot 325 Swarm Plot 329 Joint Plot 331 Matplotlib Plot 337 Line Plot 337 Bar Chart 340 Histogram Plot 342 Scatter Plot 346 Stack Plot 348 Pie Chart 350 Summary 351 Exercises and Answers 352 Chapter 8: Case Studies 359 Case Study 1: Cause of Deaths in the United States (1999–2015) 359 Data Gathering 359 Data Analysis 360 Data Visualization 365 Findings 369 Case Study 2: Analyzing Gun Deaths in the United States (2012–2014) 370 Data Gathering 371 Data Analysis 372 Data Visualization 373 Findings 380 Summary 382 Index 383 Front Matter ....Pages i-xx Introduction to Data Science with Python (Ossama Embarak)....Pages 1-83 The Importance of Data Visualization in Business Intelligence (Ossama Embarak)....Pages 85-124 Data Collection Structures (Ossama Embarak)....Pages 125-181 File I/O Processing and Regular Expressions (Ossama Embarak)....Pages 183-204 Data Gathering and Cleaning (Ossama Embarak)....Pages 205-241 Data Exploring and Analysis (Ossama Embarak)....Pages 243-292 Data Visualization (Ossama Embarak)....Pages 293-342 Case Studies (Ossama Embarak)....Pages 343-366 Back Matter ....Pages 367-374