0% found this document useful (0 votes)
43 views19 pages

Ch1 Slides

This document introduces Python for data science. It will cover using Python to store, manipulate, and analyze data. Students will learn Python basics like variables, types, scripts, and the IPython shell. They will practice calculating BMI and exploring Python's core data types like integers, floats, strings, and booleans. Reproducibility using scripts is demonstrated. The goal is to learn Python's capabilities for data handling and analysis.

Uploaded by

istioploia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views19 pages

Ch1 Slides

This document introduces Python for data science. It will cover using Python to store, manipulate, and analyze data. Students will learn Python basics like variables, types, scripts, and the IPython shell. They will practice calculating BMI and exploring Python's core data types like integers, floats, strings, and booleans. Reproducibility using scripts is demonstrated. The goal is to learn Python's capabilities for data handling and analysis.

Uploaded by

istioploia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

INTRO TO PYTHON FOR DATA SCIENCE

Hello Python!

Intro to Python for Data Science

What you will learn

Python

Specifically for Data Science

Store data

Manipulate data

Tools for data analysis

Intro to Python for Data Science

How you will learn

Intro to Python for Data Science

Python

Guido Van Rossum

General Purpose: build anything

Open Source! Free!

Python Packages, also for Data Science

Many applications and fields

Version 3.x - h!ps://www.python.org/downloads/

Intro to Python for Data Science

IPython Shell
Execute Python commands

Intro to Python for Data Science

IPython Shell

Intro to Python for Data Science

Python Script

Text Files - .py

List of Python Commands

Similar to typing in IPython Shell

Intro to Python for Data Science

Python Script

Intro to Python for Data Science

DataCamp Interface

Script

Shell

INTRO TO PYTHON FOR DATA SCIENCE

Lets practice!

INTRO TO PYTHON FOR DATA SCIENCE

Variables and Types

Intro to Python for Data Science

Variable

Specific, case-sensitive name

Call up value through variable name

1.79 m - 68.7 kg

In [1]: height = 1.79


In [2]: weight = 68.7
In [3]: height
Out[3]: 1.79

Intro to Python for Data Science

Calculate BMI
In [1]: height = 1.79
In [2]: weight = 68.7
In [3]: height
Out[3]: 1.79
In [4]: 68.7 / 1.79 ** 2
Out[4]: 21.4413
In [5]: weight / height ** 2
Out[5]: 21.4413
In [6]: bmi = weight / height ** 2
In [7]: bmi
Out[7]: 21.4413

BMI =

weight
height2

Intro to Python for Data Science

Reproducibility
!

my_script.py

height = 1.79
weight = 68.7
bmi = weight / height ** 2
print(bmi)

Output:
21.4413

Intro to Python for Data Science

Reproducibility
!

my_script.py

height = 1.79
weight = 74.2
bmi = weight / height ** 2
print(bmi)

Output:
23.1578

Intro to Python for Data Science

Python Types
In [8]: type(bmi)
Out[8]: float
In [9]: day_of_week = 5
In [10]: type(day_of_week)
Out[10]: int

Intro to Python for Data Science

Python Types (2)


In [11]: x = "body mass index"
In [12]: y = 'this works too'
In [13]: type(y)
Out[13]: str
In [14]: z = True
In [15]: type(z)
Out[15]: bool

Intro to Python for Data Science

Python Types (3)


In [16]: 2 + 3
Out[16]: 5
In [17]: 'ab' + 'cd'
Out[17]: 'abcd'

Dierent type = dierent behavior!

INTRO TO PYTHON FOR DATA SCIENCE

Lets practice!

You might also like