Data Science Projects Using Python (Dr. Pratiyush Guleria)(Z-Library)
data
No Description
1
Views
0
Downloads
0.00
Total Donations
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Page
1
(This page has no text content)
Page
2
(This page has no text content)
Page
3
Data Science Projects Using Python Step-by-step guide for data science beginners with a practical approach Dr. Pratiyush Guleria www.bpbonline.com
Page
4
First Edition 2026 Copyright © BPB Publications, India ISBN: 978-93-65894-547 All Rights Reserved. No part of this publication may be reproduced, distributed or transmitted in any form or by any means or stored in a database or retrieval system, without the prior written permission of the publisher with the exception to the program listings which may be entered, stored and executed in a computer system, but they can not be reproduced by the means of publication, photocopy, recording, or by any electronic and mechanical means. LIMITS OF LIABILITY AND DISCLAIMER OF WARRANTY The information contained in this book is true and correct to the best of author’s and publisher’s knowledge. The author has made every effort to ensure the accuracy of these publications, but the publisher cannot be held responsible for any loss or damage arising from any information in this book. All trademarks referred to in the book are acknowledged as properties of their respective owners but BPB Publications cannot guarantee the accuracy of this information. www.bpbonline.com
Page
5
Dedicated to Almighty God, my parents, and my family
Page
6
About the Author Dr. Pratiyush Guleria has a Ph.D. in computer science. He has done M.Tech in computer science with a gold medal from Himachal Pradesh University, Shimla, India. He has a consistent track record in academics throughout his career. He has cleared the State Level Eligibility Test (SLET) as well. Pratiyush Guleria has more than 17 years of experience in the IT industry and academics. He has research papers published in peer- reviewed international journals and conferences. He has been a technical program committee member and reviewer for journals and international conferences. His research interests include data mining, machine learning, and web technologies.
Page
7
About the Reviewers ❖ Gouri Sankar Dash is a seasoned technology leader and enterprise practitioner with over two decades of professional experience across enterprise platforms, large-scale system modernization, cloud architecture, data science, database engineering, cybersecurity, and applied AI. His expertise spans cloud assessment and migration, application modernization, enterprise governance, data protection, and AI-driven optimization in regulated and large-scale enterprise environments. He has led multi-million-dollar technology portfolios, architected and delivered mission-critical systems, and managed globally distributed engineering teams supporting complex enterprise systems, particularly in healthcare and financial domains. His work includes modernization of EHR platforms, enterprise database ecosystems, security and encryption frameworks, and cloud-native architectures. He is a multi-cloud certified professional and has authored and contributed to technical articles published in industry and academic journals. As a technical writer and reviewer, Gouri brings a strong practitioner’s perspective, focusing on architectural soundness, scalability, security, and real-world applicability of solutions. He is currently working with Tata Consultancy Services, America, and is part of HealthCare business group. ❖ Raja Chattopadhyay is an accomplished technology leader and technical reviewer with deep expertise in fintech, large-scale distributed systems, cloud engineering, and data security. He brings extensive professional experience in API platforms, high-performance transaction systems, external data orchestration, and enterprise-grade encryption frameworks used by major credit bureaus and identity providers.
Page
8
His work spans cloud architecture, event-driven systems, and secure data exchange models that support millions of customers and mission- critical financial operations. Raja actively contributes to the technology community through mentoring, conference speaking, and peer review of research papers. He holds multiple industry certifications and has authored several patents in data privacy, encryption, and AI-driven financial data orchestration, demonstrating his commitment to advancing secure and scalable technology solutions.
Page
9
Acknowledgement I want to express my deepest gratitude to Almighty God, my family, and my friends for their unwavering support and encouragement throughout this book's writing, especially my family and my parents. I am also grateful to BPB Publications for their guidance and expertise in bringing this book to fruition. It was a long journey of writing and conceptualizing this book, with the valuable participation and collaboration of reviewers, technical experts, and editors. I would also like to acknowledge the valuable contributions of my colleagues and co-workers during many years working in academia, who have taught me so much and provided valuable feedback on my work. Finally, I would like to thank all the readers who have taken an interest in my book and for their support in making it a reality. Your encouragement has been invaluable.
Page
10
Preface The author is optimistic that students who want to complete a thorough task will find relief in the current work. This book provides a range of real- world examples, conceptual challenges, and methodically worked-out solutions to help readers understand programming ideas through clear explanations and examples. Additionally, it covers every topic that is necessary for students to gain a thorough understanding of the fundamentals of Python. This book looks to be a great resource for anyone with programming knowledge, as well as a great place for newbies to start. The abilities needed to understand the fundamentals of data science using Python at a beginner's level are taken into account when writing this book. The book presents real-world Python examples following a simple, illustrative approach that makes it easy for students to learn and comprehend. Each chapter of the book will introduce the candidate to programming principles, along with the fundamental basics, and will feature illustrative examples of Python, including coverage of data science topics such as NumPy, Pandas data structures, data preprocessing, and visualization using Matplotlib, and so on. Although the book is written with honesty and sincerity, it is the author's hope that its flaws will be overlooked. Having said that, the author is receptive to any form of helpful critiques and recommendations for additional development. All insightful recommendations are welcome, and the author will do their utmost to include them in worthwhile additions to this work in future versions. Chapter 1: Introduction to Data Science and Python - This chapter explores the field of data science and highlights why Python is a highly popular language for data science. In addition to that, learners will also learn about the various Python libraries and the distinct features of Python. The other subjects covered in this chapter include identifiers, reserved
Page
11
words, and indentation, etc. The fundamental concepts of variables, including their data types, type conversions, and various types of operators, are all covered with comprehensive examples. Chapter 2: Conditions, Loops, Control Statements, and Functions - This chapter presents a program's flow that can be controlled and decisions made based on certain conditions using conditional and control statements. The statements like as if and if-elif-else enable the program to run a block of code only in the event that a certain condition is true or to check several conditions sequentially. The control statements modify the loop's or conditional structure's typical execution flow. Apart from it, functions are covered in this chapter. Functions are blocks of reusable code that perform specific tasks. Packages and modules are used in Python to organize and structure code for improved reuse and maintainability. Chapter 3: Lists, Tuples, and Dictionary - This chapter covers the differences between lists, tuples, and dictionaries, which are fundamental data structures in Python. Learners will explore predefined methods associated with lists and how they can be used to manipulate data effectively. This chapter will help learners understand the relationship between lists and tuples, highlighting their similarities and key differences. They will also learn about various dictionary methods used for storing and accessing key-value pairs efficiently. The chapter also introduces iterators and generators, enabling learners to work with sequences of data efficiently and in a memory-friendly way. Additionally, learners will learn about sets, which store unique elements and support useful set operations. Chapter 4: Exception Handling and File Handling - This chapter covers the subjects of file handling and exception handling. Python's exception handling mechanism lets programmers deal with errors or exceptions in an easy manner while the program is running. In addition to preventing unexpected program crashes, this guarantees that the software can recover from errors and display informative error messages. Apart from it, topics related to Python's file handling module allow you to read from and write to files. Chapter 5: Object-oriented Programming and Regular Expressions - This chapter covers key OOP principles such as classes, objects, inheritance, method overriding, encapsulation, and polymorphism. In
Page
12
addition to OOP, this chapter also introduces regular expressions (regex) in Python, a powerful tool for pattern matching and string manipulation. Regular expressions allow searching, matching, and replacing text based on specific patterns, which is particularly useful in data validation, web scraping, and text processing tasks. Chapter 6: Database Connectivity using MySQL and MongoDB - This chapter helps students understand the concept and significance of database connectivity using Python. Learners will first gain a brief overview of how Python interacts with relational databases like MySQL using the mysql.connector module to establish a connection and execute basic SQL queries. The focus then shifts to NoSQL databases, specifically MongoDB, where learners will explore its structure and how it differs from traditional relational databases. Chapter 7: NumPy Library - This chapter introduces the fundamental concepts of NumPy, one of the core libraries in Python for numerical and scientific computing. It focuses on working with arrays (ndarrays) and performing vectorized computations efficiently. Learners will learn how to create and manipulate NumPy arrays, explore basic indexing and slicing techniques, and apply arithmetic operations on arrays. The chapter also explains the use of NumPy’s universal functions (ufuncs), which provide fast element-wise operations, including mathematical, logical, and statistical functions. These tools form the foundation for high-performance computing in Python and are widely used in data analysis, machine learning, and scientific applications. Chapter 8: Introduction to Pandas Data Structure - This chapter introduces the essential components of the Pandas library, a powerful and widely used tool for data manipulation and analysis in Python. It begins with an overview of Series and DataFrame, the fundamental data structures in Pandas, followed by practical techniques for accessing and modifying data. The chapter also delves into real-world data preparation tasks, such as data cleaning and filtering, applying functions with apply(), and exploring datasets using methods like unique() and count(). Additionally, learners will learn how to read data from external CSV files and write processed data back into files, making this chapter a practical foundation for data handling in Python.
Page
13
Chapter 9: Data Cleaning and Preparation - This chapter covers foundational understanding of data preprocessing, which is essential for effective data analysis. Learners will learn to replace incorrect or inconsistent values and convert data types to ensure compatibility. In addition to it, they will explore how to rename columns for clarity, clean string data by trimming or modifying text, and filter rows based on specific conditions. Additionally, the chapter introduces indexing for accessing specific data, techniques for categorizing continuous data into bins, and methods to combine or merge columns. By the end of the chapter, learners will be able to handle missing values through imputation techniques or by removing null entries, thereby preparing clean and usable datasets. The chapter also focuses on identifying and eliminating duplicate and incorrect data entries to ensure data integrity. Chapter 10: Data Visualization Using Matplotlib - This chapter focuses on data visualization using the Matplotlib library in conjunction with Pandas. While Pandas offers robust tools for managing and analyzing structured data, Matplotlib enables users to present that data visually through various types of charts, which is essential for interpreting results in real-world applications such as business analytics and research reporting. By utilizing Pandas' built-in integration with Matplotlib, users can generate plots directly from Series and DataFrames with minimal effort. The chapter introduces the fundamentals of creating common visualizations such as line plots, bar charts, pie charts, histograms, and scatter plots using matplotlib.pyplot alongside Pandas. Chapter 11: Introduction to ML and Supervised Learning - This chapter provides learners with a practical and beginner-friendly introduction to the fundamental concepts of machine learning (ML). By the end of the chapter, learners will be able to differentiate between supervised, unsupervised, and reinforcement learning, explain how machines learn from data and make decisions without explicit programming, compare the approaches used in the three types of learning, illustrate real-world applications such as recommendation systems, customer segmentation, and autonomous agents, and identify commonly used machine learning algorithms along with their basic purposes. Chapter 12: Introduction to Unsupervised and Reinforcement Learning - This chapter covers a clear understanding of the concepts of
Page
14
unsupervised learning and reinforcement learning. Learners will be able to differentiate these approaches from supervised learning and identify where each method is most applicable in real life. Learners will learn how clustering algorithms, such as K-means, can group unlabelled data into meaningful categories, and how reinforcement learning enables an agent to make decisions based on rewards and penalties. They will gain hands-on experience by implementing simple Python programs for clustering. Appendix A: Simple Projects Using Pandas - This chapter presents a collection of small applications that demonstrate how to use the Pandas library in Python for analyzing data stored in CSV files. Each example is designed to be simple, clear, and practical so that readers can easily follow and apply the concepts. The applications include analyzing students’ performance, summarizing sales records, and extracting insights from employee salary data. Examples also show how Python data structures such as lists, tuples, and dictionaries can be converted into DataFrames and then saved or used as CSV files for further analysis. Through these hands-on exercises, readers are introduced to essential analytical techniques that form the foundation of data-driven decision making, which is a key component of modern data science workflows. Appendix B: Simple Projects Using Matplotlib - This chapter presents a collection of small applications that demonstrate how to use the Matplotlib library in Python for visualizing data stored in CSV files. Each example is designed to be simple, clear, and practical so that readers can easily follow and apply the concepts. The applications include plotting using a line chart, visualizing product sales through bar charts, and examining employee salary distribution with histograms. Additional case studies cover data visualization and analysis using illustrative examples that combine real- world scenarios with effective visual techniques, allowing readers to see how charts and plots can turn raw data into meaningful insights.
Page
15
Code Bundle and Coloured Images Please follow the link to download the Code Bundle and the Coloured Images of the book: https://rebrand.ly/1154w9p The code bundle for the book is also hosted on GitHub at https://github.com/bpbpublications/Data-Science-Projects-Using- Python. In case there’s an update to the code, it will be updated on the existing GitHub repository. We have code bundles from our rich catalogue of books and videos available at https://github.com/bpbpublications. Check them out! Errata We take immense pride in our work at BPB Publications and follow best practices to ensure the accuracy of our content to provide with an indulging reading experience to our subscribers. Our readers are our mirrors, and we use their inputs to reflect and improve upon human errors, if any, that may have occurred during the publishing processes involved. To let us maintain the quality and help us reach out to any readers who might be having difficulties due to any unforeseen errors, please write to us at : errata@bpbonline.com Your support, suggestions and feedbacks are highly appreciated by the BPB Publications’ Family. At www.bpbonline.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on BPB books and eBooks. You can check our social media handles below:
Page
16
Instagram Facebook Linkedin YouTube Get in touch with us at: business@bpbonline.com for more details. Piracy If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at business@bpbonline.com with a link to the material. If you are interested in becoming an author If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, please visit www.bpbonline.com. We have worked with thousands of developers and tech professionals, just like you, to help them share their insights with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Reviews Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions. We at BPB can understand what you think about our products, and our authors can see your feedback on their book. Thank you! For more information about BPB, please visit www.bpbonline.com. Join our Discord space Join our Discord workspace for latest updates, offers, tech happenings around the world, new releases, and sessions with the authors: https://discord.bpbonline.com
Page
17
(This page has no text content)
Page
18
Table of Contents 1. Introduction to Data Science and Python Introduction Structure Objectives Artificial intelligence and machine learning with Python Choosing Python for data science Installing Python on Windows Python in online and offline environments Python libraries Features of Python Identifiers Rules of naming identifiers Reserved words Indentation Comments Variables and data types Python data types Type conversion Operators in Python Arithmetic operators Comparison operators Logical operators Assignment operator
Page
19
Bitwise operators Membership operators Identity operators Conclusion Points to remember Key terms Multiple choice questions Answers Questions 2. Conditions, Loops, Control Statements, and Functions Introduction Structure Objectives Conditional statements Loop control statements Break statement Continue statement For loop While loop Nested loop Functions User-defined and pre-defined functions Basic structure of a Python user-defined function Function scope Function with a return statement Pre-defined functions String functions Numeric functions List or sequence functions
Page
20
Math functions in Python Random number functions Lambda function Lambda function versus def keyword for functions map() function Modules Creating a module Packages Conclusion Points to remember Key terms Multiple choice questions Answers Questions 3. Lists, Tuples, and Dictionary Introduction Structure Objectives Brief introduction to chapter flow Lists Slicing in lists Tuples Dictionary Iterators Python generators Sets Conclusion Points to remember
The above is a preview of the first 20 pages. Register to read the complete e-book.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
AI guide
# Data Science Projects Using Python
## 【One-Line Pitch】
A hands-on, beginner-friendly guide that takes you from Python fundamentals through database connectivity and data analysis libraries, with practical examples and worked solutions for every concept. Ideal for students and newcomers who want to learn data science by doing rather than just reading.
## 【Book Arc】
- **Opening (~0%–10%)**: Introduces data science as a field and explains why Python is the go-to language, covering installation, Jupyter Notebook setup, basic syntax, variables, data types, and operators—including arithmetic, comparison, logical, bitwise, membership, and identity operators.
- **Early (~10%–23%)**: Moves into control flow with conditional statements, loops (for, while, nested), and functions—covering user-defined and pre-defined functions, scope, return statements, and built-in string/numeric/list functions. Then transitions into core data structures: lists, tuples, dictionaries, and sets, plus iterators and generators.
- **Early (~23%–32%)**: Covers file handling (open, read, write, close, with statement) and introduces object-oriented programming—classes, objects, constructors, inheritance, polymorphism, abstraction, and encapsulation, with regex pattern matching for text processing.
- **Middle (~32%–48%)**: Dives into database connectivity, starting with SQL fundamentals (DDL, DML, DQL, DCL, TCL) and MySQL integration using Connector/Python, then moves to MongoDB with PyMongo—including installation, CRUD operations, and JSON data import.
- **Middle (~48%–end)**: Focuses on data science libraries: NumPy for numerical computing (arrays, conditional operations like np.where), and Pandas for data manipulation—covering Series, DataFrames, indexing with loc, and filtering rows based on conditions.
## 【Key Takeaways】
- **Python's simplicity is its superpower for data science** (Early): Clean, English-like syntax and readability make it accessible for beginners compared to C++ or Java, while its interpreted nature allows line-by-line execution and rapid experimentation.
- **Master control flow before touching data** (Early): Conditional statements, loops, and functions form the backbone of all data processing scripts—understanding break, continue, and return statements is non-negotiable for writing efficient code.
- **Choose the right data structure for the job** (Early): Lists are ordered and mutable, tuples are immutable for fixed data, dictionaries store key-value pairs with unique keys, and sets prevent duplicates—each serves a distinct purpose in data organization.
- **Object-oriented programming enables code reuse** (Early): Classes act as blueprints, inheritance promotes code reuse, polymorphism allows the same method to behave differently, and abstraction hides complexity—essential for building maintainable data pipelines.
- **Database connectivity bridges Python and real-world data** (Middle): SQL commands (DDL, DML, DQL) structure relational data in MySQL, while MongoDB offers a flexible, document-based alternative—both accessible through Python connectors like Connector/Python and PyMongo.
- **NumPy powers numerical computing** (Middle): Arrays with conditional operations like np.where enable vectorized data preprocessing—categorizing or labeling values based on thresholds without writing explicit loops.
- **Pandas is the workhorse for data manipulation** (Middle): Series and DataFrames handle tabular data, with loc for row access and comparison operators for filtering—the foundation for any data analysis workflow.
## 【Reading Tips】
- **Skim the multiple-choice questions at each chapter's end**—they serve as quick self-assessments to confirm you've grasped the key concepts before moving forward.
- **Deep-read the worked examples** (like the while loop printing 1–5 or the addition function with return)—they demonstrate the exact syntax and logic flow you'll need for your own projects.
- **Pay special attention to the database chapters**—the MySQL and MongoDB sections include installation guides and complete CRUD operations, which are the most practical skills for real-world data work.
- **Don't skip the "Points to Remember" sections**—they condense each chapter's essential facts into digestible summaries perfect for revision.
- **Practice the NumPy and Pandas examples in Jupyter Notebook**—the interactive environment makes it easy to experiment with the code and see outputs immediately.
## 【Coverage Limits】
This guide covers the book's progression from Python basics through databases and data science libraries, but the excerpts do not include the final visualization chapters (Matplotlib projects) or any advanced machine learning content.
##
Passage locations
Page 10
rious Python libraries and the distinct features of Python. The other subjects covered in this chapter include identifiers, reserved Bitwise operators Member...
View in text
Excerpt 2
ng a loop, you can pass the function and the list to map(), which applies the function to each element and returns the results. In the example, the square()...
View in text
Excerpt 3
lasses in order to carry out the actions that are specified. Abstract classes act as blueprints for other classes and cannot be instantiated directly. The ba...
View in text
Excerpt 4
7. How do you connect Python with MongoDB using the PyMongo library? Explain the steps briefly. 8. Write a Python program to insert a document into a MongoDB...
View in text
Recommended for You
{{#thumbnailUrl}}
{{/thumbnailUrl}}
{{^thumbnailUrl}}
{{/thumbnailUrl}}
Loading recommended books...
Failed to load, please try again later
Tip the Site
Scan the WeChat Pay or Alipay code to tip. No login required.
WeChat Pay
Alipay