Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning Jupyter 5 - Second Edition

You're reading from  Learning Jupyter 5 - Second Edition

Product type Book
Published in Aug 2018
Publisher
ISBN-13 9781789137408
Pages 282 pages
Edition 2nd Edition
Languages

Table of Contents (18) Chapters

Title Page
Packt Upsell
Contributors
Preface
Introduction to Jupyter Jupyter Python Scripting Jupyter R Scripting Jupyter Julia Scripting Jupyter Java Coding Jupyter JavaScript Coding Jupyter Scala Jupyter and Big Data Interactive Widgets Sharing and Converting Jupyter Notebooks Multiuser Jupyter Notebooks What's Next? Other Books You May Enjoy Index

Python pandas in Jupyter


One of the most widely used features of Python is pandas. The pandas are built-in libraries of data analysis packages that can be used freely. In this example, we will develop a Python script that uses pandas to see if there is any affect of using them in Jupyter.

I am using the Titanic dataset from https://www.kaggle.com/c/titanic/data. I am sure that the same data is available from a variety of sources.

Note

Note that you have to sign up for Kaggle in order to download the data. It's free.

Here is our Python script that we want to run in Jupyter:

from pandas import * 
training_set = read_csv('train.csv') 
training_set.head() 
male = training_set[training_set.Sex == 'male'] 
female = training_set[training_set.Sex =='female'] 
womens_survival_rate = float(sum(female.Survived))/len(female) 
mens_survival_rate = float(sum(male.Survived))/len(male) 
womens_survival_rate, mens_survival_rate

The result is that we calculate the survival rates of the passengers based on sex.

We...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}