SlideShare a Scribd company logo
Introduction to Python
What is Python? - Python is a programming language designed
by Guido van Rossum and was initially
released in 1991
- Named after the British comedy troupe,
Monty Python’s Flying Circus
- It is an interpreted language
- Its instructions are not directly executed by the
target machine, but read and executed by
some other program
- Code can be executed “on the fly”, but will use
more CPU time
- External libraries can enhance the capabilities
of Python
- Ex -- NumPy, iPython, pandas, matplotlib
Python Features
Elegant syntax
Easy to use language
Large standard library
Basic data types
Object-oriented programming with classes and
multiple inheritance
Free software
Python Version?
- Python 2 was started in 2000
- Python 2.7 was released in 2010
- Will lose support in 2020
- Python 3.0 was released in 2008
- More and more libraries are
starting to support Python 3.4
- Which to use?
- A lot more expansive support and
resources for Python 2
- Some Python 3 features are
backwards compatible
- BUT the future is looking towards
Python 3
Uses for Python
- Server automation, libraries for
webapps
- Game development
- Animation
- Scientific computing and Data
Science
- Visualizing and analyzing data
How to Install Python
Can download it from project site and install
libraries individually
(https://www.python.org/downloads/))
Comes pre-installed with Mac
Download Python with Anaconda distribution
(https://www.anaconda.com/download/)
Development Environment
- Terminal
- IDLE editor
- Jupyter Notebook (previously called
iPython Notebook)
- try.jupyter.org
Jupyter Notebook
The browser hosts it, but it’s pulling data
from the directory you’re running on your
computer
Notebooks are downloadable as .ipynb files
Cell → where you run the code
- also possible to write markdown
- # Comments in Python
Kernel is what your cell is running, the code
that’s running
Shortcuts
Shift + Enter → runs code
Tab → for autocomplete methods
Shift + Tab → expanded view of
help popups
What is Data Science? Data-driven science
Interdisciplinary field about scientific method to
extract knowledge and insights from data in various
forms
Includes machine learning, data mining, analytics,
visualization, scraping, artificial intelligence etc
Source: https://datajobs.com/what-is-data-science
Data Science Concepts and Process
Data science relies on statistical analysis, BUT it
is more than statistical analysis
Emphasis on project definition and collaboration
Data Science Project Lifecycle
Project goal -- why are we doing this?
Data collection, quality, sufficiency, and
management
Exploratory analysis
Model evaluation and sufficiency
Presentation to stakeholders, project
documentation, and reproducibility
Source: http://www.glassdoor.com
Intro to the
Python
Language
For Data Analysis:
- Get by with basic, key concepts
- Become familiar with libraries
- Use the technologies to your advantage
Python vs
Java
Java
- Static typing →
everything must be
explicitly declared
- Verbose → so many
words!
- Not compact
Python
- Dynamic typing → an
assignment statement
binds a name to an
object, the object can
be of any type, can be
later assigned to an
object of a different
type
- Concise → straight to
the point!
- Compact → “It can all
be apprehended at
once in one’s head”
Differences between Python and Java
Java Python
Source: https://pythonconquerstheuniverse.wordpress.com/2009/10/03/python-java-a-side-by-side-comparison/
Differences between Python and Java
Java Python
Source: https://pythonconquerstheuniverse.wordpress.com/2009/10/03/python-java-a-side-by-side-comparison/
Numbers
- Integers, floats
- Basic arithmetic: addition, subtraction, multiplication, division
- Python 3 uses “true division” → 3/2 = 1.5
- Python 2 uses “classic division” → 3/2 = 1
- Cast → float(3)/2 = 1.5
- Import python3 functions into python2 →
from __future__ import division
3/2 = 1.5
- Powers → 2**3 = 8
Variable Assignment
Strings
Strings use single or double quotes, depending on formatting
String Manipulation
Strings are sequences and can be indexed
Grab the length of a string using len()
Use : to perform slicing
Strings are immutable →
once created, they cannot
be changed or replaced,
but you can concatenate
Lists
Lists can work similarly to strings -- they use the
len() function and square brackets to access data
Source: https://developers.google.com/edu/python/lists
Assignment with = will not make a copy, it
will make the 2 variables point to the same
same list
Tuples
- Sequence of immutable Python objects, like lists
- Tuples cannot be changed (immutable), but lists can
- Fixed size, whereas lists are dynamic
- You cannot remove elements from a tuple (no remove or pop method)
- Faster than lists -- if you ever need to define a constant set of values to iterate through, tuples are
preferable
Source: https://www.tutorialspoint.com/python/python_tuples.htm
Dictionaries
- Associative array, also known as hash
- Any key in the dictionary is associated or mapped to a value
- Unordered key-value-pairs
Python
Libraries
SciKit-Learn
Machine learning module built on top of SciPy
Started in 2007 by David Cournapeau as a Google
Summer of Code project
Currently maintained by volunteers
Source: https://github.com/scikit-learn/scikit-learn,
http://scikit-learn.org/stable/index.html
1. Install Dependency using Python Package Manager
a. Package that code depends on
MAC: pip install -U scikit-learn
WINDOWS: python -m pip install -U pip
Or with conda:
conda install scikit-learn
Predicting
Gender
Example program taken from
Siraj Raval: https://youtu.be/T5pRlIbr6gg
Breaking it Down
2. Import Dependency and
sub-module → tree (to build a decision
tree)
3. Create data sets in lists (list of lists)
4. Store decision tree classifier
initialize using fit method
5. Print to terminal
pandas
Popular python package for data analysis &
manipulation
Well suited for ordered and unordered data,
tabular data, arbitrary matrix data,
observational/statistical data
- Python package pro
- Install using conda or pip
pip install pandas
Source: https://github.com/pandas-dev/pandas
Popular Baby
Names
Using Pandas and matplotlib for
Data Analysis
1. Environment Setup
2. Create data set
3. Get data → read it from text
4. Prepare data → making sure data is clean
5. Analyze data
6. Present data
Source:
http://nbviewer.jupyter.org/urls/bitbucket.org/hrojas/learn-pandas/raw/master/lessons/01%20-%20Lesson.ipynb
https://www.babycenter.com/top-baby-names-2016.htm
https://www.ssa.gov/oact/babynames/index.html
Environment Setup
Create Data Set
Merge the lists together using
zip()
Create Data Set → Create DataFrame
Create Data Set → Create .csv
Make a .csv out of the DataFrame
Location sets where you want the .csv to be saved
- Prefacing the location string with r escapes the string if you output
the file to a different directory
Get Data → Read .csv
read_csv pulls in the data from the
csv into the console
- Reads the first entry as the header
Get Data → Edit .csv
Prepare Data → Make sure it’s clean
- Births are type int64
meaning, no floats or
alpha numeric
characters will be
present
Analyze Data
- Find the most popular baby name with highest birth rate
- Sort the DataFrame and select the top row
- OR use the max() attribute to find the max value
Present Data → Plot the DataFrame
- Plot the Births column and label the graph to show the highest point on the
graph → with the table, the end user can navigate the data clearly
- plot() is a pandas attribute that lets you plot the data in the dataframe
References,
Resources and
Further Study
Siraj Raval - Learn Python for Data Science (short, bite sized):
https://www.youtube.com/playlist?list=PL2-dafEMk2A6QKz1m
rk1uIGfHkC1zZ6UU
Introduction to Data Science in Python (U of M):
https://www.coursera.org/learn/python-data-analysis
Python and Data Sciences Courses:
https://www.kaggle.com/wiki/Tutorials
Step by Step Approach…:
http://bigdata-madesimple.com/step-by-step-approach-to-per
form-data-analysis-using-python/

More Related Content

What's hot

Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...
Edureka!
 
Python
PythonPython
Python
PythonPython
Python
대갑 김
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
Aakashdata
 
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Edureka!
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Ayshwarya Baburam
 
Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3
Chariza Pladin
 
Python basic
Python basicPython basic
Python basic
Saifuddin Kaijar
 
Python basics
Python basicsPython basics
Python basics
Hoang Nguyen
 
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Edureka!
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
Srinivas Narasegouda
 
Python
PythonPython
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
Rasan Samarasinghe
 
Python Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & stylePython Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & style
Kevlin Henney
 
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaPython Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Edureka!
 
Beginning Python Programming
Beginning Python ProgrammingBeginning Python Programming
Beginning Python Programming
St. Petersburg College
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
AkshayAggarwal79
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
AnirudhaGaikwad4
 
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Edureka!
 

What's hot (20)

Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...
 
Python
PythonPython
Python
 
Python
PythonPython
Python
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
 
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
 
Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3
 
Python basic
Python basicPython basic
Python basic
 
Python basics
Python basicsPython basics
Python basics
 
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Python
PythonPython
Python
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Python Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & stylePython Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & style
 
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaPython Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
 
Beginning Python Programming
Beginning Python ProgrammingBeginning Python Programming
Beginning Python Programming
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
 

Similar to Introduction To Python

Data Science With Python | Python For Data Science | Python Data Science Cour...
Data Science With Python | Python For Data Science | Python Data Science Cour...Data Science With Python | Python For Data Science | Python Data Science Cour...
Data Science With Python | Python For Data Science | Python Data Science Cour...
Simplilearn
 
Python Powered Data Science at Pivotal (PyData 2013)
Python Powered Data Science at Pivotal (PyData 2013)Python Powered Data Science at Pivotal (PyData 2013)
Python Powered Data Science at Pivotal (PyData 2013)
Srivatsan Ramanujam
 
Python introduction
Python introductionPython introduction
Python introductionRoger Xia
 
A Whirlwind Tour Of Python
A Whirlwind Tour Of PythonA Whirlwind Tour Of Python
A Whirlwind Tour Of Python
Asia Smith
 
Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)
Ian Huston
 
Synopsis Software Training ppt.pptx
Synopsis Software Training ppt.pptxSynopsis Software Training ppt.pptx
Synopsis Software Training ppt.pptx
HarpreetSinghBagga2
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on python
Shubham Yadav
 
Introduction to Python Programming Language For Artificial Intelligence
Introduction to Python Programming Language For Artificial IntelligenceIntroduction to Python Programming Language For Artificial Intelligence
Introduction to Python Programming Language For Artificial Intelligence
saraahmed870035
 
Python PPT
Python PPTPython PPT
Python PPT
Edureka!
 
Python for Big Data Analytics
Python for Big Data AnalyticsPython for Big Data Analytics
Python for Big Data Analytics
Edureka!
 
Hadoop and Pig at Twitter__HadoopSummit2010
Hadoop and Pig at Twitter__HadoopSummit2010Hadoop and Pig at Twitter__HadoopSummit2010
Hadoop and Pig at Twitter__HadoopSummit2010
Yahoo Developer Network
 
Python for data science
Python for data sciencePython for data science
Python for data science
Tanzeel Ahmad Mujahid
 
Basic of python for data analysis
Basic of python for data analysisBasic of python for data analysis
Basic of python for data analysis
Pramod Toraskar
 
Adarsh_Masekar(2GP19CS003).pptx
Adarsh_Masekar(2GP19CS003).pptxAdarsh_Masekar(2GP19CS003).pptx
Adarsh_Masekar(2GP19CS003).pptx
hkabir55
 
Dc python meetup
Dc python meetupDc python meetup
Dc python meetup
Jeffrey Clark
 
Researh toolbox - Data analysis with python
Researh toolbox  - Data analysis with pythonResearh toolbox  - Data analysis with python
Researh toolbox - Data analysis with python
Umair ul Hassan
 
Researh toolbox-data-analysis-with-python
Researh toolbox-data-analysis-with-pythonResearh toolbox-data-analysis-with-python
Researh toolbox-data-analysis-with-python
Waternomics
 
Scaling PyData Up and Out
Scaling PyData Up and OutScaling PyData Up and Out
Scaling PyData Up and Out
Travis Oliphant
 
Webinar: Mastering Python - An Excellent tool for Web Scraping and Data Anal...
Webinar:  Mastering Python - An Excellent tool for Web Scraping and Data Anal...Webinar:  Mastering Python - An Excellent tool for Web Scraping and Data Anal...
Webinar: Mastering Python - An Excellent tool for Web Scraping and Data Anal...
Edureka!
 

Similar to Introduction To Python (20)

Data Science With Python | Python For Data Science | Python Data Science Cour...
Data Science With Python | Python For Data Science | Python Data Science Cour...Data Science With Python | Python For Data Science | Python Data Science Cour...
Data Science With Python | Python For Data Science | Python Data Science Cour...
 
Python Powered Data Science at Pivotal (PyData 2013)
Python Powered Data Science at Pivotal (PyData 2013)Python Powered Data Science at Pivotal (PyData 2013)
Python Powered Data Science at Pivotal (PyData 2013)
 
Python introduction
Python introductionPython introduction
Python introduction
 
A Whirlwind Tour Of Python
A Whirlwind Tour Of PythonA Whirlwind Tour Of Python
A Whirlwind Tour Of Python
 
Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)
 
Synopsis Software Training ppt.pptx
Synopsis Software Training ppt.pptxSynopsis Software Training ppt.pptx
Synopsis Software Training ppt.pptx
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on python
 
Introduction to Python Programming Language For Artificial Intelligence
Introduction to Python Programming Language For Artificial IntelligenceIntroduction to Python Programming Language For Artificial Intelligence
Introduction to Python Programming Language For Artificial Intelligence
 
Python PPT
Python PPTPython PPT
Python PPT
 
Python for Big Data Analytics
Python for Big Data AnalyticsPython for Big Data Analytics
Python for Big Data Analytics
 
Hadoop and Pig at Twitter__HadoopSummit2010
Hadoop and Pig at Twitter__HadoopSummit2010Hadoop and Pig at Twitter__HadoopSummit2010
Hadoop and Pig at Twitter__HadoopSummit2010
 
Python for data science
Python for data sciencePython for data science
Python for data science
 
Basic of python for data analysis
Basic of python for data analysisBasic of python for data analysis
Basic of python for data analysis
 
Adarsh_Masekar(2GP19CS003).pptx
Adarsh_Masekar(2GP19CS003).pptxAdarsh_Masekar(2GP19CS003).pptx
Adarsh_Masekar(2GP19CS003).pptx
 
Dc python meetup
Dc python meetupDc python meetup
Dc python meetup
 
Researh toolbox - Data analysis with python
Researh toolbox  - Data analysis with pythonResearh toolbox  - Data analysis with python
Researh toolbox - Data analysis with python
 
Researh toolbox-data-analysis-with-python
Researh toolbox-data-analysis-with-pythonResearh toolbox-data-analysis-with-python
Researh toolbox-data-analysis-with-python
 
Scaling PyData Up and Out
Scaling PyData Up and OutScaling PyData Up and Out
Scaling PyData Up and Out
 
Session 2
Session 2Session 2
Session 2
 
Webinar: Mastering Python - An Excellent tool for Web Scraping and Data Anal...
Webinar:  Mastering Python - An Excellent tool for Web Scraping and Data Anal...Webinar:  Mastering Python - An Excellent tool for Web Scraping and Data Anal...
Webinar: Mastering Python - An Excellent tool for Web Scraping and Data Anal...
 

Recently uploaded

The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 

Recently uploaded (20)

The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 

Introduction To Python

  • 2. What is Python? - Python is a programming language designed by Guido van Rossum and was initially released in 1991 - Named after the British comedy troupe, Monty Python’s Flying Circus - It is an interpreted language - Its instructions are not directly executed by the target machine, but read and executed by some other program - Code can be executed “on the fly”, but will use more CPU time - External libraries can enhance the capabilities of Python - Ex -- NumPy, iPython, pandas, matplotlib
  • 3. Python Features Elegant syntax Easy to use language Large standard library Basic data types Object-oriented programming with classes and multiple inheritance Free software
  • 4. Python Version? - Python 2 was started in 2000 - Python 2.7 was released in 2010 - Will lose support in 2020 - Python 3.0 was released in 2008 - More and more libraries are starting to support Python 3.4 - Which to use? - A lot more expansive support and resources for Python 2 - Some Python 3 features are backwards compatible - BUT the future is looking towards Python 3
  • 5. Uses for Python - Server automation, libraries for webapps - Game development - Animation - Scientific computing and Data Science - Visualizing and analyzing data
  • 6. How to Install Python Can download it from project site and install libraries individually (https://www.python.org/downloads/)) Comes pre-installed with Mac Download Python with Anaconda distribution (https://www.anaconda.com/download/) Development Environment - Terminal - IDLE editor - Jupyter Notebook (previously called iPython Notebook) - try.jupyter.org
  • 7. Jupyter Notebook The browser hosts it, but it’s pulling data from the directory you’re running on your computer Notebooks are downloadable as .ipynb files Cell → where you run the code - also possible to write markdown - # Comments in Python Kernel is what your cell is running, the code that’s running Shortcuts Shift + Enter → runs code Tab → for autocomplete methods Shift + Tab → expanded view of help popups
  • 8. What is Data Science? Data-driven science Interdisciplinary field about scientific method to extract knowledge and insights from data in various forms Includes machine learning, data mining, analytics, visualization, scraping, artificial intelligence etc Source: https://datajobs.com/what-is-data-science
  • 9. Data Science Concepts and Process Data science relies on statistical analysis, BUT it is more than statistical analysis Emphasis on project definition and collaboration Data Science Project Lifecycle Project goal -- why are we doing this? Data collection, quality, sufficiency, and management Exploratory analysis Model evaluation and sufficiency Presentation to stakeholders, project documentation, and reproducibility
  • 11. Intro to the Python Language For Data Analysis: - Get by with basic, key concepts - Become familiar with libraries - Use the technologies to your advantage
  • 12. Python vs Java Java - Static typing → everything must be explicitly declared - Verbose → so many words! - Not compact Python - Dynamic typing → an assignment statement binds a name to an object, the object can be of any type, can be later assigned to an object of a different type - Concise → straight to the point! - Compact → “It can all be apprehended at once in one’s head”
  • 13. Differences between Python and Java Java Python Source: https://pythonconquerstheuniverse.wordpress.com/2009/10/03/python-java-a-side-by-side-comparison/
  • 14. Differences between Python and Java Java Python Source: https://pythonconquerstheuniverse.wordpress.com/2009/10/03/python-java-a-side-by-side-comparison/
  • 15. Numbers - Integers, floats - Basic arithmetic: addition, subtraction, multiplication, division - Python 3 uses “true division” → 3/2 = 1.5 - Python 2 uses “classic division” → 3/2 = 1 - Cast → float(3)/2 = 1.5 - Import python3 functions into python2 → from __future__ import division 3/2 = 1.5 - Powers → 2**3 = 8
  • 17. Strings Strings use single or double quotes, depending on formatting
  • 18. String Manipulation Strings are sequences and can be indexed Grab the length of a string using len() Use : to perform slicing Strings are immutable → once created, they cannot be changed or replaced, but you can concatenate
  • 19. Lists Lists can work similarly to strings -- they use the len() function and square brackets to access data Source: https://developers.google.com/edu/python/lists Assignment with = will not make a copy, it will make the 2 variables point to the same same list
  • 20. Tuples - Sequence of immutable Python objects, like lists - Tuples cannot be changed (immutable), but lists can - Fixed size, whereas lists are dynamic - You cannot remove elements from a tuple (no remove or pop method) - Faster than lists -- if you ever need to define a constant set of values to iterate through, tuples are preferable Source: https://www.tutorialspoint.com/python/python_tuples.htm
  • 21. Dictionaries - Associative array, also known as hash - Any key in the dictionary is associated or mapped to a value - Unordered key-value-pairs
  • 23. SciKit-Learn Machine learning module built on top of SciPy Started in 2007 by David Cournapeau as a Google Summer of Code project Currently maintained by volunteers Source: https://github.com/scikit-learn/scikit-learn, http://scikit-learn.org/stable/index.html 1. Install Dependency using Python Package Manager a. Package that code depends on MAC: pip install -U scikit-learn WINDOWS: python -m pip install -U pip Or with conda: conda install scikit-learn
  • 24. Predicting Gender Example program taken from Siraj Raval: https://youtu.be/T5pRlIbr6gg
  • 25. Breaking it Down 2. Import Dependency and sub-module → tree (to build a decision tree) 3. Create data sets in lists (list of lists) 4. Store decision tree classifier initialize using fit method 5. Print to terminal
  • 26. pandas Popular python package for data analysis & manipulation Well suited for ordered and unordered data, tabular data, arbitrary matrix data, observational/statistical data - Python package pro - Install using conda or pip pip install pandas Source: https://github.com/pandas-dev/pandas
  • 28. Using Pandas and matplotlib for Data Analysis 1. Environment Setup 2. Create data set 3. Get data → read it from text 4. Prepare data → making sure data is clean 5. Analyze data 6. Present data Source: http://nbviewer.jupyter.org/urls/bitbucket.org/hrojas/learn-pandas/raw/master/lessons/01%20-%20Lesson.ipynb https://www.babycenter.com/top-baby-names-2016.htm https://www.ssa.gov/oact/babynames/index.html
  • 30. Create Data Set Merge the lists together using zip()
  • 31. Create Data Set → Create DataFrame
  • 32. Create Data Set → Create .csv Make a .csv out of the DataFrame Location sets where you want the .csv to be saved - Prefacing the location string with r escapes the string if you output the file to a different directory
  • 33. Get Data → Read .csv read_csv pulls in the data from the csv into the console - Reads the first entry as the header
  • 34. Get Data → Edit .csv
  • 35. Prepare Data → Make sure it’s clean - Births are type int64 meaning, no floats or alpha numeric characters will be present
  • 36. Analyze Data - Find the most popular baby name with highest birth rate - Sort the DataFrame and select the top row - OR use the max() attribute to find the max value
  • 37. Present Data → Plot the DataFrame - Plot the Births column and label the graph to show the highest point on the graph → with the table, the end user can navigate the data clearly - plot() is a pandas attribute that lets you plot the data in the dataframe
  • 38.
  • 39.
  • 40. References, Resources and Further Study Siraj Raval - Learn Python for Data Science (short, bite sized): https://www.youtube.com/playlist?list=PL2-dafEMk2A6QKz1m rk1uIGfHkC1zZ6UU Introduction to Data Science in Python (U of M): https://www.coursera.org/learn/python-data-analysis Python and Data Sciences Courses: https://www.kaggle.com/wiki/Tutorials Step by Step Approach…: http://bigdata-madesimple.com/step-by-step-approach-to-per form-data-analysis-using-python/