Opportunity Through Data Textbook
  • Opportunity Through Data Textbook
  • Introduction
    • What is Data Science?
    • Introduction to Data Science: Exploratory Musical Analysis
  • Module 1
    • Introduction to Programming
      • The Command Line
      • Installing Programs
      • Python and the Command Line
      • Jupyter Notebook
    • Introduction to Python
      • Building Blocks of Python - Data Types and Variables
      • Functions
      • Formatting and Syntax
    • Math Review
      • Variables and Functions
      • Intro to Graphs
  • Module 2
    • Data Structures
      • Lists
      • Dictionaries
      • Tables
    • Programming Logic
      • Loops
      • Logical Operators
      • Conditionality
  • Module 3
    • Introduction to Probability
      • Probability and Sampling
    • Introduction to Statistics
      • Mean & Variance
      • Causality & Randomness
  • Module 4
    • Packages
    • Intro to NumPy
      • NumPy (continued)
  • Module 5
    • Introduction to Pandas
      • Introduction to Dataframes
      • Groupby and Join
    • Working with Data
    • Data Visualization
      • Matplotlib
      • Introduction to Data Visualization
  • Appendix
    • Table Utilities
    • Area of More Complicated Shapes
    • Introduction to Counting
    • Slope and Distance
    • Short Circuiting
    • Linear Regression
    • Glossary
  • Extension: Classification
    • Classification
    • Test Sets and Training Sets
    • Nearest Neighbors
  • Extension: Introduction to SQL
    • Introduction to SQL
    • Table Operations
      • Tables and Queries
      • Joins
  • Extension: Central Limit Theorem
    • Overview
    • Probability Distributions
      • Bernoulli Distribution
      • Uniform Distribution (Discrete)
      • Random Variables, Expectation, Variance
      • Discrete and Continuous Distributions
      • Uniform Distribution (Continuous)
      • Normal Distribution
    • Central Limit Theorem in Action
    • Confidence Intervals
  • Extension: Object-Oriented Programming
    • Object-Oriented Programming
      • Classes
      • Instantiation
      • Dot Notation
      • Mutability
  • Extension: Introduction to Excel
    • Introduction to Excel
      • Terminology and Interface
      • Getting Started with Analysis and Charts
      • Basics of Manipulating Data
    • Additional Features in Excel
      • Macros
      • The Data Tab
      • Pivot Tables
Powered by GitBook
On this page

Was this helpful?

  1. Module 1
  2. Introduction to Programming

Jupyter Notebook

How can we organize our code and see the results?

PreviousPython and the Command LineNextIntroduction to Python

Last updated 4 years ago

Was this helpful?

KEY TERMS

  • Jupyter Notebook: an application that allows us to run and visualize multiple lines of Python code, display charts and graphs, and save and organize our code

  • notebook: a term used to refer to a Jupyter Notebook or .ipynb file

  • code cell: a cell in a Jupyter Notebook that can contain code

Note: This guide on how to use Jupyter Notebook assumes that it has already been installed on your machine. If this is not the case, you can follow the instructions on the on how to install Jupyter Notebook.

Up until now, we have been using the command python in the Command Prompt in order to write our Python commands. However, you may have noticed that writing code line by line can be time-consuming. The Command Prompt is also not very useful for looking at tables or displaying graphs, which is something that data scientists often need to do.

In this chapter, we will introduce you to Jupyter Notebook. Jupyter Notebook is an application that allows us to run and visualize multiple lines of Python code as well as display various types of charts and graphs.

To run Jupyter Notebook, we can navigate to the directory that our Jupyter Notebook file is in (or the directory in which we want to create a new Jupyter Notebook file) and run the command jupyter notebook in the Command Prompt. This should open a tab in our web browser that will look something like this:

You'll notice that this window looks really similar to our File Explorer! Our current directory is shown in the gray bar and the folders and files in this directory are listed underneath. To open a Jupyter Notebook file (which we will refer to from now on as a notebook), we can double-click on it. This is what a notebook might look like:

To run the code in a code cell (the shaded boxes containing Python code), first click on that cell to activate it. When selected, the code cell will be highlighted with a little green or blue rectangle. Next, either click on the ▶| Run button at the top of the notebook, or hold down the shift key and press the return or enter key.

In Figure 2 above, all of the code cells have been run and the results are displayed below each cell. Note the similarities between Python commands run in the Command Prompt and those run in the Jupyter Notebook. For example, a variable declared in a previous line/cell can still be accessed in a later line/cell.

Try it out! The best way to get familiar with how to use a Jupyter Notebook is to write some code!

Jupyter Notebook website
Figure 1: Jupyter Notebook
Figure 2: Temp.ipynb