Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Become a Python Data Analyst
Become a Python Data Analyst

Become a Python Data Analyst: Perform exploratory data analysis and gain insight into scientific computing using Python

By Alvaro Fuentes
$25.99
Book Aug 2018 178 pages 1st Edition
eBook
$21.99
Print
$25.99
Subscription
$15.99 Monthly
eBook
$21.99
Print
$25.99
Subscription
$15.99 Monthly

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
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
Buy Now
Table of content icon View table of contents Preview book icon Preview Book

Become a Python Data Analyst

The Anaconda Distribution and Jupyter Notebook

In this book, you will learn the basic concepts of data analysis using Python. In the first chapter, we will learn how to install the Anaconda distribution, which contains all the software needed for this book. We will also get to know Jupyter Notebook, which is the computing environment where we will do all of our work. Something nice about this book is that we take a hands-on practical approach that will help you to master the tools very effectively.

The following are the main topics that will be covered in this chapter:

  • The Anaconda distribution and the problems it solve
  • How to install it in our computer and get ready to start working
  • Jupyter Notebook, where we will perform our computations and analysis
  • Some useful commands and keyboard shortcuts used in Jupyter Notebook

The Anaconda distribution

Anaconda is a free, easy-to-install package management and environment management Python distribution created for developers and data scientists to make package management and deployment in scientific computing, data science, statistical analysis, and machine learning an easy task. It is software that is produced and distributed by Continuum Analytics and is available for free download at https://www.anaconda.com/download/.

Anaconda is a toolbox, a ready-to-use collection of related tools for doing data analytics with Python. The individual tools are also available for free download, but it is definitely more convenient to get the whole toolbox. This is the main problem that Anaconda solves, saving you the time it takes to look for every individual tool and install them on your system. In addition, Anaconda also takes care of package dependencies and other potential conflicts and problems that are the outcome of installing Python packages individually.

Installing Anaconda

On opening the previously mentioned URL, we are given download options for each operating system. So, here, you must look for the appropriate installer for your operating system. You will see two installers: one is for Python 3.6 and the other is for Python 2.7. In this book, we will be using Python 3.6:

Let's download the latest version of the Anaconda software and save in our Downloads folder.

Here, we choose the 64-bit installer of Anaconda 5.2 for Windows, since we will be working on a Windows environment in this book. Installation for macOS and Linux will also be similar.

Installing Anaconda is very simple; it is no different from any other software you have installed before. Double-click on the .exe file and install the software on your system. The steps are easy and you'll get the normal prompts you see when installing software:

  1. Click on Next in the first installer dialog box.
  2. Then, we have the license agreement, where we can click on I Agree after going through the terms and conditions of the software.
  3. From the options, select Just Me and click Next.
  4. Select the default installation destination folder and click Next.
  5. Next, it asks you for the environment variables and whether you want to register Anaconda as your default Python. Check both boxes and click on Install.
  6. Once the installation is complete, click on Finish in the installer dialog box.

Jupyter Notebook

Jupyter Notebook is a web application that allows you to create and share documents that contain live code, equations, visualizations, and explanatory text. It is the application we will be working with in this book. Its uses include data cleaning and transformation, numerical simulation, statistical modeling, machine learning, and much more. Jupyter Notebook is similar to a canvas, or an environment, that allows you to use a programming language, in our case Python, to perform computations and to show the results in a very convenient way.

It is very convenient if you're doing some kind of analytical work, because often you want to include explanatory text, the code that produced the results, and the visualizations, which are shown in Jupyter Notebook. So it is a very convenient way of doing analytical work with any programming language, especially with Python. The Jupyter project was born out of the IPython project in 2014. Now, it has evolved to support interactive data science and scientific computing across many other programming languages, so you can use the Jupyter Notebook with many other programming languages (up to almost 20 languages). The name Jupyter comes from Julia, Python, and R, which were the three programming languages that were first supported.

Creating your own Jupyter Notebook

To start Anaconda and open a Jupyter Notebook, we click Anaconda Prompt from our list of installed programs. Anaconda Prompt is a Terminal where you can type commands. But first, let's create a folder called PythonDataScience on our desktop. This will be the directory where all the Python code that we code and run for this book in Jupyter Notebook will be stored.

Once the Terminal is open, navigate to PythonDataScience by typing the command cd Desktop/PythonDataScience and pressing Enter. To start the Jupyter Notebook application inside this directory, type the command jupyter notebook and hit Enter. This will start the application and you will see the main screen of the application opened in a tab on your browser:

You have three tabs here. One is the Files tab, where you will see all the files that you have inside the folder where you started the application. On the Running tab, you will see the things that you have running, either Terminals or Notebooks. The Clusters tab displays details about parallel computing, but we will not be using this feature in this book.

The main tab that we will be using in this book is the Files tab. To create a new Jupyter Notebook, go to New|Python 3 Notebook:

This will start a new file, which is the Jupyter Notebook where you can start coding and running your Python code.

Notebook user interfaces

Jupyter Notebook has some very useful user interfaces that display important information and notifications while you work on the Notebook. Let's go to Help and click on the first option, User Interface Tour, to take a quick look and get familiar with the interfaces of Jupyter Notebook:

The following are the main interfaces you will find on the main page of the Notebook:

  • Title (1): This is your filename and you can also change the filename of your Notebook.
  • Menu bar (2): Similar to any other desktop application, you have a menu bar where you can find different actions to do with the Notebook.
  • Toolbar (3): This is located below the menu bar and contains little icons to perform some commonly performed actions, such as saving a file, cutting cells, pasting cells, moving cells, and so on.
  • Mode indicator (4): This is located on the right-hand side of the menu bar. The Notebook has two modes, Edit mode and Command mode. Command mode has many keyboard shortcuts that you can use. In this mode, no icon is displayed in the indicator area, and the actions you can perform in this mode are actions that have to do with the file itself, such as saving the file, copying and pasting cells, and so on. Edit mode allows you to write code or text in a cell, if you are in a cell. When you are in Edit mode, you will see a little pencil in the indicator area.
A Jupyter Notebook is composed of two types of cells, code cells and text cells. The border of a selected cell will be green when you are in Edit mode. To go back to Command mode from Edit mode, you can press the Esc key or Ctrl + M. There are many keyboard shortcuts that you can use and there is a list in the Help menu.
  • Kernel indicator (5): This displays the status of the system's computation progress. To interrupt the computations that are in progress, you can use the stop button located on the toolbar.
  • Notification area (6): This area will display messages such as saving the file, or interrupting the kernel, and so on, and you will see the actions that you're performing in the notification area.

Using the Jupyter Notebook

Lets open a new Jupyter Notebook and create a new Python 3 Notebook, then name the Notebook as FirstPractice. As mentioned earlier, the Notebook is made out of cells, and you have two types of cells: the default cell type, which is called the code cell, and the other type of cells are text cells. We have a code cell every time we open a Notebook where you can execute any Python statement.

Running code in a code cell

We will run a few simple code statements and learn how to run those statements, and also learn how to change a cell type from code to text and vice versa. Let's execute the first code by typing 1 + 1 in the first code cell, and if you run the code of the cell with the run cell button, you will see the following output in the line below the code cell:

Next, let's create a variable, a, assign its value as 10, and run the code. Now this variable has been created, but since we didn’t create any code to compute the variable, we won’t see any output. But the statement was run, and now, if you use this variable, add 1 to it, and run the code, you will see the following result:

Now, let's see an example of the for syntax using a variable, i:

The code will tell the Notebook to print the value of i if and when the value is within the range of 10, which gives the preceding result.

Running markdown syntax in a text cell

As mentioned, the default type of each cell is a code cell, where we write Python expressions. The other type of cell that we have is a text cell, and a text cell is used to actually write text. In the cell below the output, let's type This is regular text. To tell the Notebook that this is not Python code and this is actually some text, you go to Cell | Cell Type | Markdown. Let’s run this now and you will find that what you get as output is just the text, the same text we entered:

Jupyter also allows us to format the text in many ways by using markdown syntax. If you are not familiar with markdown, you can go to Help|Markdown, where you will be taken to one of the GitHub help pages.

The markdown that you can use in Jupyter is the same markdown you use in GitHub.

There are many ways you can style and format your text; you can find all the information at: https://help.github.com/articles/basic-writing-and-formatting-syntax/. For this chapter, we will just look at the headings that are very important.

To create a heading, we add one to six # symbols before the heading text. The number of # symbols determines the size of the heading, starting from one to six # symbols, the largest to smallest heading, as follows:

# The largest heading
## The second largest heading
###### The smallest heading

The following screenshot shows the output for the preceding syntax:

If you run them in a code cell, you will get a bunch of Python commands, but we know that we want to see these as formatted text, so we need to tell the Notebook that these are actually texts by marking the cell type as markdown, and when you run the cell you get the preceding result.

Styles and formats

You can introduce other formats, such as bold, italic, strikethrough, and bold and italic. The following table shows the different styles and their corresponding syntax with an example of each:

You can also introduce quotes, for which the syntax is denoted by, the > symbol. Run a markdown cell with the following syntax:

In the words of Abraham Lincoln:
> Pardon my French

This will give the following result:

We find the style and format of the texts remains the same, similar to the line of text preceding the >, but the quoted text is a little indented from the normal indentation.

Lists

You can use or * before one or more lines to create a bulleted list. You can also use 1, 2, 3, and so on, to create a numbered or ordered list:

- George Washington
- John Adams
- Thomas Jefferson

1. James Madison
2. James Monroe
3. John Quincy Adams

On running the markdown syntax, we get the following result:

You will get a lot more styling and formatting syntax from a website that you can use in the Notebook.

Useful keyboard shortcuts

It is very annoying to use the mouse every time you want to run the cell or to transform a code cell into a markdown cell. To ease these tasks, we have a lot of keyboard shortcuts that you can use in Jupyter. Let's look at some of the most important ones.

To run a cell, for example, if you want to run the computation of 1 + 2, you can hit Alt + Enter. This shortcut will run the code in the cell and create a new cell below the output line. But if you just want to run the computation, you will press Ctrl + Enter; this will get the Notebook to run the code in that cell and show you the output, but no new cell will be created. If you want to insert a new cell below the current cell, you can press B, and then pressing A will create new cells above the current cell. This is very useful when you're working interactively within the Notebook and you want to create many cells to have more room to work.

If you find yourself using a command very often and you want to learn the shortcut key; you can go to Help|Keyboard Shortcuts. You will see a list of all the keyboard shortcuts that you can use in the Notebook.

Another very useful thing is how to transform cells from code cells to markdown cells. If you want to transform a code cell into a text cell, press the M key; this will get you from Edit mode to Command mode. Also, if you are in Command mode and you want to transform the cell into a code cell or Edit mode, press the Esc key.

Summary

In this chapter, we learned about the Anaconda distribution. We also installed all the software that we will use in the course, which is contained in the Anaconda distribution, and we learned about Jupyter Notebook and the basics of working with Jupyter Notebooks; about the code cells, the markdown cells, and the most useful keyboard command shortcuts to work with Jupyter and make our workflow more efficient.

In the next chapter, we will learn about NumPy, which is the core library for doing numerical computing and is at the core of every scientific computing project in the PythonX system.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Cover all fundamental libraries for operation and manipulation of Python for data analysis
  • Implement real-world datasets to perform predictive analytics with Python
  • Access modern data analysis techniques and detailed code with scikit-learn and SciPy

Description

Python is one of the most common and popular languages preferred by leading data analysts and statisticians for working with massive datasets and complex data visualizations. Become a Python Data Analyst introduces Python’s most essential tools and libraries necessary to work with the data analysis process, right from preparing data to performing simple statistical analyses and creating meaningful data visualizations. In this book, we will cover Python libraries such as NumPy, pandas, matplotlib, seaborn, SciPy, and scikit-learn, and apply them in practical data analysis and statistics examples. As you make your way through the chapters, you will learn to efficiently use the Jupyter Notebook to operate and manipulate data using NumPy and the pandas library. In the concluding chapters, you will gain experience in building simple predictive models and carrying out statistical computation and analysis using rich Python tools and proven data analysis techniques. By the end of this book, you will have hands-on experience performing data analysis with Python.

What you will learn

Explore important Python libraries and learn to install Anaconda distribution Understand the basics of NumPy Produce informative and useful visualizations for analyzing data Perform common statistical calculations Build predictive models and understand the principles of predictive analytics
Estimated delivery fee Deliver to Chile

Standard delivery 10 - 13 business days

$19.95

Premium delivery 3 - 6 business days

$40.95
(Includes tracking information)

Product Details

Country selected

Publication date : Aug 31, 2018
Length 178 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781789531701
Category :
Concepts :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
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
Buy Now
Estimated delivery fee Deliver to Chile

Standard delivery 10 - 13 business days

$19.95

Premium delivery 3 - 6 business days

$40.95
(Includes tracking information)

Product Details


Publication date : Aug 31, 2018
Length 178 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781789531701
Category :
Concepts :

Table of Contents

8 Chapters
Preface Chevron down icon Chevron up icon
1. The Anaconda Distribution and Jupyter Notebook Chevron down icon Chevron up icon
2. Vectorizing Operations with NumPy Chevron down icon Chevron up icon
3. Pandas - Everyone's Favorite Data Analysis Library Chevron down icon Chevron up icon
4. Visualization and Exploratory Data Analysis Chevron down icon Chevron up icon
5. Statistical Computing with Python Chevron down icon Chevron up icon
6. Introduction to Predictive Analytics Models Chevron down icon Chevron up icon
7. Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Top Reviews
No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela