Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Learn Python by Building Data Science Applications
Learn Python by Building Data Science Applications

Learn Python by Building Data Science Applications: A fun, project-based guide to learning Python 3 while building real-world apps

Arrow left icon
Profile Icon Kats Profile Icon Katz
Arrow right icon
zł59.99 zł125.99
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.8 (4 Ratings)
eBook Aug 2019 482 pages 1st Edition
eBook
zł59.99 zł125.99
Paperback
zł157.99
Subscription
Free Trial
Arrow left icon
Profile Icon Kats Profile Icon Katz
Arrow right icon
zł59.99 zł125.99
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.8 (4 Ratings)
eBook Aug 2019 482 pages 1st Edition
eBook
zł59.99 zł125.99
Paperback
zł157.99
Subscription
Free Trial
eBook
zł59.99 zł125.99
Paperback
zł157.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
Table of content icon View table of contents Preview book icon Preview Book

Learn Python by Building Data Science Applications

Preparing the Workspace

Welcome! We're very excited to start learning and building things with you! However, we need to get ourselves ready first.

In this chapter, we'll learn how to download and install everything you'll need throughout the book, including Python itself, all the Python packages that we'll need, and two development tools we will be using extensively: Jupyter and Visual Studio Code (VS Code). After that, we'll go through a brief overview of Jupyter and VS Code interfaces. Finally, you will run your very first line of Python, so we need to ensure that everything is ready before we dive in.

In this chapter, we'll cover the following:

  • The minimum computer configuration required
  • How to install the Anaconda distribution
  • How to download the code for this book
  • Setting up and getting familiar with VS Code and Jupyter
  • Running your first line...

Technical requirements

Python can be very humble and does not require an advanced computer. In fact, you can run Python on a $10 Raspberry Pi or an Arduino board! The code and data we use in this book do not require any special computational power, any laptop, or any computer made after 2008. At least 2 GB of RAM, 20 GB of disk space, and an internet connection should suffice. Your operating system (OS) shouldn't be a problem either, as Python and all the tools we will use are cross-platform and work on Windows, macOS, and Linux.

Throughout the book, we'll use two main tools to write the code: Jupyter and VS Code. Both of them are free and aren't demanding.

All the code for the book is publicly available and free to access at https://github.com/PacktPublishing/Learn-Python-by-Building-Data-Science-Applications.

Installing Python

There are multiple Python distributions, starting with the original, vanilla Python, which is accessible at https://www.python.org/. Data analysis, however, adds unique requirements for packaging (https://www.youtube.com/watch?v=QjXJLVINsSA&feature=youtu.be&t=3555). In this book, we use Anaconda, which is an open source and free Python distribution, designed for data science and machine learning. Anaconda's main features include a smooth installation of data science packages (many of which run C and Fortran languages under the hood) and conda, which is a great package and environment manager (we will talk more about environments and conda later in Chapter 9, Shell, Git, Conda, and More – at Your Command). Conveniently, the Anaconda distribution installs all the packages (https://docs.anaconda.com/anaconda/packages/pkg-docs/) we need in this...

Downloading materials for running the code

All code in this book is also available as a separate archive of files—either Python scripts or Jupyter notebooks. You can download the full archive and follow along with the book using the relevant code from GitHub (https://github.com/PacktPublishing/Learn-Python-by-Building-Data-Science-Applications). Everything is stored on GitHub, which is an online service for code storage with version control. We will discuss both Git and GitHub in Chapter 9, Shell, Git, Conda, and More – at Your Command, but in this case, you won't need version control, so it is easier to download everything as an archive. Just use the Clone or download button on the right side (1), and select Download ZIP (2):

Once the download is complete, unzip the file and move it to a convenient location. This folder will be our main workspace throughout...

Working with VS Code

VS Code is invaluable for Python development and experimentation. VS Code—not to be confused with Visual Studio, which is a commercial product—is a sophisticated, completely free, and open source text editor created by Microsoft. It is language-agnostic and will work perfectly with Python, JavaScript, Java, or any other language. VS Code has hundreds of built-in features and thousands of great plugins to expand its capabilities.

In order to install VS Code, head to its main web page, https://code.visualstudio.com/, and download the package for your OS. The installation is pretty straightforward; there is no need to change any of the default settings. Assuming you installed VS Code as part of the previous steps, you now need to open the VS Code application. Next, switch to the plugin marketplace menu (as shown in the following screenshot), type...

Beginning with Jupyter

Another development environment we'll use is Jupyter. If you have installed Anaconda, then Jupyter is already on your machine, as it is one of the tools that come with Anaconda. To start using Jupyter, we need to run it from the Terminal (you might need to open a new Terminal to update the paths). The following code will run a newer version of the tool's frontend face, and that is what we'll use:

$ jupyter lab

Alternatively, it also supports an older version of the frontend via Jupyter Notebook. The two have their differences, but we'll stick with the lab.

The app's behavior depends on the folder from which it was started; it is more convenient to run it directly from the project's root folder. That's why it is so handy that VS Code's Terminal opens in a workspace folder by itself, as we don't need to navigate...

Pre-flight check

Before we proceed to the content of this book, let's ensure our code can actually be executed by running the simplest possible code in Jupyter. To do this, let's create a test notebook and run some code to ensure everything works as intended. Click on the Python 3 square in the Notebook section. A new tab should open, called Untitled.ipynb.

First, the blue line highlighted represents the selected cell in the notebook. Each cell represents a separate snippet of code, which is executed simultaneously in one step. Let's write our very first line of code in this cell:

print('Hello world')

Now, hit Shift + Enter. This shortcut executes the selected cells in Python and outputs the result on the next line. It also automatically creates a new input cell if there are none, as shown in the following screenshot. The number on the left gives a hint...

Summary

In this chapter, we prepared our working environment for the journey ahead. In particular, we installed the Anaconda Scientific Python Distribution with Python 3.7.2, which includes all the packages we'll need throughout the course of this book. We also installed and learned about the basics of VS Code, which is a sophisticated and interactive development environment that will be our primary tool for writing arbitrary code, and Jupyter, which we use for experimentation and analysis. Finally, we discussed and even ran some code already! We did this in Jupyter, which is a coding environment that is perfect for prototyping, experimentation, analysis, and educational purposes.

In the next chapter, we'll begin our introduction to Python, learning about variables, variable assignment, and Python's basic data types.

...

Questions

  1. What version of Python do we use?
  2. Will it work on a Windows PC?
  3. Do I need to install any additional packages?
  4. What is a Jupyter Notebook?
  5. When and why should I use Jupyter Notebooks?
  6. When should I switch to VS Code?
  7. Can I run the code from this book on my smartphone/tablet?
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn the basics of developing applications with Python and deploy your first data application
  • Take your first steps in Python programming by understanding and using data structures, variables, and loops
  • Delve into Jupyter, NumPy, Pandas, SciPy, and sklearn to explore the data science ecosystem in Python

Description

Python is the most widely used programming language for building data science applications. Complete with step-by-step instructions, this book contains easy-to-follow tutorials to help you learn Python and develop real-world data science projects. The “secret sauce” of the book is its curated list of topics and solutions, put together using a range of real-world projects, covering initial data collection, data analysis, and production. This Python book starts by taking you through the basics of programming, right from variables and data types to classes and functions. You’ll learn how to write idiomatic code and test and debug it, and discover how you can create packages or use the range of built-in ones. You’ll also be introduced to the extensive ecosystem of Python data science packages, including NumPy, Pandas, scikit-learn, Altair, and Datashader. Furthermore, you’ll be able to perform data analysis, train models, and interpret and communicate the results. Finally, you’ll get to grips with structuring and scheduling scripts using Luigi and sharing your machine learning models with the world as a microservice. By the end of the book, you’ll have learned not only how to implement Python in data science projects, but also how to maintain and design them to meet high programming standards.

Who is this book for?

If you want to learn Python or data science in a fun and engaging way, this book is for you. You’ll also find this book useful if you’re a high school student, researcher, analyst, or anyone with little or no coding experience with an interest in the subject and courage to learn, fail, and learn from failing. A basic understanding of how computers work will be useful.

What you will learn

  • Code in Python using Jupyter and VS Code
  • Explore the basics of coding – loops, variables, functions, and classes
  • Deploy continuous integration with Git, Bash, and DVC
  • Get to grips with Pandas, NumPy, and scikit-learn
  • Perform data visualization with Matplotlib, Altair, and Datashader
  • Create a package out of your code using poetry and test it with PyTest
  • Make your machine learning model accessible to anyone with the web API

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Aug 30, 2019
Length: 482 pages
Edition : 1st
Language : English
ISBN-13 : 9781789533064
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning

Product Details

Publication date : Aug 30, 2019
Length: 482 pages
Edition : 1st
Language : English
ISBN-13 : 9781789533064
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 537.97
Python Programming Blueprints
zł221.99
Learn Programming in Python with Cody Jackson
zł157.99
Learn Python by Building Data Science Applications
zł157.99
Total 537.97 Stars icon

Table of Contents

25 Chapters
Section 1: Getting Started with Python Chevron down icon Chevron up icon
Preparing the Workspace Chevron down icon Chevron up icon
First Steps in Coding - Variables and Data Types Chevron down icon Chevron up icon
Functions Chevron down icon Chevron up icon
Data Structures Chevron down icon Chevron up icon
Loops and Other Compound Statements Chevron down icon Chevron up icon
First Script – Geocoding with Web APIs Chevron down icon Chevron up icon
Scraping Data from the Web with Beautiful Soup 4 Chevron down icon Chevron up icon
Simulation with Classes and Inheritance Chevron down icon Chevron up icon
Shell, Git, Conda, and More – at Your Command Chevron down icon Chevron up icon
Section 2: Hands-On with Data Chevron down icon Chevron up icon
Python for Data Applications Chevron down icon Chevron up icon
Data Cleaning and Manipulation Chevron down icon Chevron up icon
Data Exploration and Visualization Chevron down icon Chevron up icon
Training a Machine Learning Model Chevron down icon Chevron up icon
Improving Your Model – Pipelines and Experiments Chevron down icon Chevron up icon
Section 3: Moving to Production Chevron down icon Chevron up icon
Packaging and Testing with Poetry and PyTest Chevron down icon Chevron up icon
Data Pipelines with Luigi Chevron down icon Chevron up icon
Let's Build a Dashboard Chevron down icon Chevron up icon
Serving Models with a RESTful API Chevron down icon Chevron up icon
Serverless API Using Chalice Chevron down icon Chevron up icon
Best Practices and Python Performance Chevron down icon Chevron up icon
Assessments Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.8
(4 Ratings)
5 star 25%
4 star 0%
3 star 0%
2 star 75%
1 star 0%
Hoi Nguyen Aug 17, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book with smart coding included!
Amazon Verified review Amazon
George Paquin Jun 14, 2024
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
So far, I've not been able to get Anaconda to install on linux mint. So my experience is. "What a pain". Might be a decent product, but so far it's disappointing. I think I'm going to have to set up a new system just to run it. Or find a linux mentor.
Feefo Verified review Feefo
Tony Apr 25, 2022
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
I am three quarters finished woth the book and there are many hurdles for a beginner of python. Number one the book uses an extremely complicated database about world war 2 battles. The database should have been less complicated since the book is supposedly meant for beginners of python. This complicated database is used again and again throughout the book for various tasks which impedes the learning process. Why couldn't the author have chosen a simpler database? The book starts out showing elements of the python language. At times the lessons are not bad. But then the author goes into this confusing complicated datascraping example which he uses for the next half of the book thereby confusing the reader. Why wasn't the datascraping explained to a beginner audience?? The section on data cleaning is super complicated using regex and was not explained well at all. I have about one quarter of the book left and I will update my review if i notice any improvement. The bottom line is that the author does not explain concepts to a beginner python audience like the book claims. He throws around terms like the reader is familiar with them like " pipes" without adequately explaining them. I am familiar with C and Java and I was still confused with the author's explanations. The bottom line: This is just NOT a book for python beginners and the explanations of real complicated concepts are lacking at best and down right confusing at worst.UPDATE: I continued to read the book and I just about gave up. From chapter 13 to the end gets progessively complicated and so disappointing, I had high hopes for this book to teach me python and data science at the same time, while it barely teaches either one. The problem here is that the author just does NOT explain every line of code. ANd the lines of code which he bothers to explain are not explained adequately. He just throws SUPER complicated code at you and expects you to understand it. On page 5 he states: " The book is designed for complete beginners..." Really?? If you are a beginner wouldn't you want every line of code explained? Or would you like the author to throw code at you and ASSUME you understand it? I wish this book would have been like the book: Artificial Intelligence and Deep Learning with Python: Every Line of Code Explained For Readers New to AI and New to Python. In that book each and every line of python code IS explained , profusely. I am extremely dissapointed.
Amazon Verified review Amazon
Ricardo Cavallí Feb 11, 2020
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
Quite a bit of the code does not work and the author doesn't respond to social media for help...I would return it if it wasn't digital.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.