SlideShare uma empresa Scribd logo
1 de 40
Baixar para ler offline
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/

Mais conteúdo relacionado

Mais procurados

Presentation on python
Presentation on pythonPresentation on python
Presentation on pythonwilliam john
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An IntroductionSwarit Wadhe
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programmingSrinivas Narasegouda
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python ProgrammingKamal Acharya
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Pedro Rodrigues
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming KrishnaMildain
 
Python course syllabus
Python course syllabusPython course syllabus
Python course syllabusSugantha T
 
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...Edureka!
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-pythonAakashdata
 
Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert QA TrainingHub
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1Kirti Verma
 

Mais procurados (20)

Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Presentation on python
Presentation on pythonPresentation on python
Presentation on python
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An Introduction
 
Python ppt
Python pptPython ppt
Python ppt
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming
 
Python by Rj
Python by RjPython by Rj
Python by Rj
 
Introduction to the Python
Introduction to the PythonIntroduction to the Python
Introduction to the Python
 
Python
PythonPython
Python
 
Python course syllabus
Python course syllabusPython course syllabus
Python course syllabus
 
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
Python Sequence | Python Lists | Python Sets & Dictionary | Python Strings | ...
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
 
Python basics
Python basicsPython basics
Python basics
 
Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert Best Python Online Training with Live Project by Expert
Best Python Online Training with Live Project by Expert
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 

Semelhante a 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 PythonAsia 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.pptxHarpreetSinghBagga2
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on pythonShubham 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 Intelligencesaraahmed870035
 
Python PPT
Python PPTPython PPT
Python PPTEdureka!
 
Python for Big Data Analytics
Python for Big Data AnalyticsPython for Big Data Analytics
Python for Big Data AnalyticsEdureka!
 
Hadoop and Pig at Twitter__HadoopSummit2010
Hadoop and Pig at Twitter__HadoopSummit2010Hadoop and Pig at Twitter__HadoopSummit2010
Hadoop and Pig at Twitter__HadoopSummit2010Yahoo Developer Network
 
Basic of python for data analysis
Basic of python for data analysisBasic of python for data analysis
Basic of python for data analysisPramod Toraskar
 
Adarsh_Masekar(2GP19CS003).pptx
Adarsh_Masekar(2GP19CS003).pptxAdarsh_Masekar(2GP19CS003).pptx
Adarsh_Masekar(2GP19CS003).pptxhkabir55
 
Researh toolbox-data-analysis-with-python
Researh toolbox-data-analysis-with-pythonResearh toolbox-data-analysis-with-python
Researh toolbox-data-analysis-with-pythonWaternomics
 
Researh toolbox - Data analysis with python
Researh toolbox  - Data analysis with pythonResearh toolbox  - Data analysis with python
Researh toolbox - Data analysis with pythonUmair ul Hassan
 
Scaling PyData Up and Out
Scaling PyData Up and OutScaling PyData Up and Out
Scaling PyData Up and OutTravis 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!
 

Semelhante a 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...
 

Último

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 

Último (20)

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 

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/