SlideShare a Scribd company logo
INTERMEDIATE PYTHON FOR DATA SCIENCE
Basic Plots 

with Matplotlib
Intermediate Python for Data Science
!● Visualization
"
"
"● Data Structures
#● Control Structures
$● Case Study
Intermediate Python for Data Science
Data Visualization
● Very important in Data Analysis
● Explore data
● Report insights
Intermediate Python for Data Science
Source: GapMinder, Wealth and Health of Nations
Intermediate Python for Data Science
Matplotlib
In [1]: import matplotlib.pyplot as plt
In [2]: year = [1950, 1970, 1990, 2010]
In [3]: pop = [2.519, 3.692, 5.263, 6.972]
In [4]: plt.plot(year, pop)
In [5]: plt.show()
x y
Intermediate Python for Data Science
Matplotlib year = [1950, 1970, 1990, 2010]
pop = [2.519, 3.692, 5.263, 6.972]
Intermediate Python for Data Science
Sca er plot
In [1]: import matplotlib.pyplot as plt
In [2]: year = [1950, 1970, 1990, 2010]
In [3]: pop = [2.519, 3.692, 5.263, 6.972]
In [4]: plt.plot(year, pop)
In [5]: plt.show()
Intermediate Python for Data Science
Sca er plot
In [1]: import matplotlib.pyplot as plt
In [2]: year = [1950, 1970, 1990, 2010]
In [3]: pop = [2.519, 3.692, 5.263, 6.972]
In [4]: plt. (year, pop)
In [5]: plt.show()
scatter
INTERMEDIATE PYTHON FOR DATA SCIENCE
Let’s practice!
INTERMEDIATE PYTHON FOR DATA SCIENCE
Histogram
Intermediate Python for Data Science
Histogram
● Explore dataset
● Get idea about distribution
0 1 2 3 4 5 6
0 2 4 6
Intermediate Python for Data Science
Matplotlib
In [1]: import matplotlib.pyplot as plt
Help on function hist in module matplotlib.pyplot:
hist(x, bins=10, range=None, normed=False, weights=None,

cumulative=False, bottom=None, histtype='bar', align='mid',

orientation='vertical', rwidth=None, log=False, color=None,

label=None, stacked=False, hold=None, data=None, **kwargs)
Plot a histogram.
Compute and draw the histogram of *x*. The return value is a
tuple (*n*, *bins*, *patches*) or ([*n0*, *n1*, ...],

*bins*, [*patches0*, *patches1*,...]) if the input contains

multiple data.
...
In [2]: help(plt.hist)
Intermediate Python for Data Science
Matplotlib example
In [3]: values = [0,0.6,1.4,1.6,2.2,2.5,2.6,3.2,3.5,3.9,4.2,6]
In [4]: plt.hist(values, bins = 3)
In [5]: plt.show()
Intermediate Python for Data Science
Population Pyramid
INTERMEDIATE PYTHON FOR DATA SCIENCE
Let’s practice!
INTERMEDIATE PYTHON FOR DATA SCIENCE
Customization
Intermediate Python for Data Science
Data Visualization
● Many options
● Different plot types
● Many customizations
● Choice depends on
● Data
● Story you want to tell
Intermediate Python for Data Science
Basic Plot
population.py
import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100]
pop = [2.538, 2.57, 2.62, ..., 10.85]
plt.plot(year, pop)
plt.show()
!
Intermediate Python for Data Science
Axis labels
import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100]
pop = [2.538, 2.57, 2.62, ..., 10.85]
plt.plot(year, pop)
plt.show()
population.py!
plt.xlabel('Year')
plt.ylabel('Population')
Intermediate Python for Data Science
Axis labels
import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100]
pop = [2.538, 2.57, 2.62, ..., 10.85]
plt.plot(year, pop)
plt.show()
population.py!
plt.xlabel('Year')
plt.ylabel('Population')
Intermediate Python for Data Science
Title
import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100]
pop = [2.538, 2.57, 2.62, ..., 10.85]
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.show()
population.py!
plt.title('World Population Projections')
Intermediate Python for Data Science
Title
import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100]
pop = [2.538, 2.57, 2.62, ..., 10.85]
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.show()
population.py!
plt.title('World Population Projections')
Intermediate Python for Data Science
Ticks
import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100]
pop = [2.538, 2.57, 2.62, ..., 10.85]
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.title('World Population Projections')
plt.show()
population.py!
plt.yticks([0, 2, 4, 6, 8, 10])
Intermediate Python for Data Science
Ticks
import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100]
pop = [2.538, 2.57, 2.62, ..., 10.85]
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.title('World Population Projections')
plt.show()
population.py!
plt.yticks([0, 2, 4, 6, 8, 10])
Intermediate Python for Data Science
Ticks (2)
import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100]
pop = [2.538, 2.57, 2.62, ..., 10.85]
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10],
plt.show()
population.py!
['0', '2B', '4B', '6B', '8B', '10B'])
Intermediate Python for Data Science
Ticks (2)
import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100]
pop = [2.538, 2.57, 2.62, ..., 10.85]
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10],
plt.show()
population.py!
['0', '2B', '4B', '6B', '8B', '10B'])
Intermediate Python for Data Science
Add historical data
import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100]
pop = [2.538, 2.57, 2.62, ..., 10.85]
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10],

['0', '2B', '4B', '6B', '8B', '10B'])
plt.show()
population.py!
# Add more data
year = [1800, 1850, 1900] + year
pop = [1.0, 1.262, 1.650] + pop
Intermediate Python for Data Science
Add historical data
import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100]
pop = [2.538, 2.57, 2.62, ..., 10.85]
plt.plot(year, pop)
plt.xlabel('Year')
plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10],

['0', '2B', '4B', '6B', '8B', '10B'])
plt.show()
population.py!
# Add more data
year = [1800, 1850, 1900] + year
pop = [1.0, 1.262, 1.650] + pop
Intermediate Python for Data Science
Before vs A er
INTERMEDIATE PYTHON FOR DATA SCIENCE
Let’s practice!

More Related Content

What's hot

Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)
PyData
 
Introduction to numpy
Introduction to numpyIntroduction to numpy
Introduction to numpy
Gaurav Aggarwal
 
Python Pyplot Class XII
Python Pyplot Class XIIPython Pyplot Class XII
Python Pyplot Class XII
ajay_opjs
 
NumPy
NumPyNumPy
NumPy/SciPy Statistics
NumPy/SciPy StatisticsNumPy/SciPy Statistics
NumPy/SciPy Statistics
Enthought, Inc.
 
Introduction to numpy Session 1
Introduction to numpy Session 1Introduction to numpy Session 1
Introduction to numpy Session 1
Jatin Miglani
 
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser BootsmaDSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
Deltares
 
Python grass
Python grassPython grass
Python grass
Margherita Di Leo
 
Tokyo webmining 2017-10-28
Tokyo webmining 2017-10-28Tokyo webmining 2017-10-28
Tokyo webmining 2017-10-28
Kimikazu Kato
 
Network Analysis with networkX : Real-World Example-2
Network Analysis with networkX : Real-World Example-2Network Analysis with networkX : Real-World Example-2
Network Analysis with networkX : Real-World Example-2
Kyunghoon Kim
 
Icpp power ai-workshop 2018
Icpp power ai-workshop 2018Icpp power ai-workshop 2018
Icpp power ai-workshop 2018
Ganesan Narayanasamy
 
Sea Amsterdam 2014 November 19
Sea Amsterdam 2014 November 19Sea Amsterdam 2014 November 19
Sea Amsterdam 2014 November 19
GoDataDriven
 
Scientific Computing with Python - NumPy | WeiYuan
Scientific Computing with Python - NumPy | WeiYuanScientific Computing with Python - NumPy | WeiYuan
Scientific Computing with Python - NumPy | WeiYuan
Wei-Yuan Chang
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpy
Faraz Ahmed
 
Code Generation
Code GenerationCode Generation
Code Generation
Dmitri Nesteruk
 
Designing linear algebra into Julia
Designing linear algebra into JuliaDesigning linear algebra into Julia
Designing linear algebra into Julia
Jiahao Chen
 
Faster persistent data structures through hashing
Faster persistent data structures through hashingFaster persistent data structures through hashing
Faster persistent data structures through hashing
Johan Tibell
 
End-to-end Big Data Projects with Python - StampedeCon Big Data Conference 2017
End-to-end Big Data Projects with Python - StampedeCon Big Data Conference 2017End-to-end Big Data Projects with Python - StampedeCon Big Data Conference 2017
End-to-end Big Data Projects with Python - StampedeCon Big Data Conference 2017
StampedeCon
 
Numpy Talk at SIAM
Numpy Talk at SIAMNumpy Talk at SIAM
Numpy Talk at SIAM
Enthought, Inc.
 
Performance
PerformancePerformance
Performance
Yonatan Levin
 

What's hot (20)

Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)
 
Introduction to numpy
Introduction to numpyIntroduction to numpy
Introduction to numpy
 
Python Pyplot Class XII
Python Pyplot Class XIIPython Pyplot Class XII
Python Pyplot Class XII
 
NumPy
NumPyNumPy
NumPy
 
NumPy/SciPy Statistics
NumPy/SciPy StatisticsNumPy/SciPy Statistics
NumPy/SciPy Statistics
 
Introduction to numpy Session 1
Introduction to numpy Session 1Introduction to numpy Session 1
Introduction to numpy Session 1
 
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser BootsmaDSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
 
Python grass
Python grassPython grass
Python grass
 
Tokyo webmining 2017-10-28
Tokyo webmining 2017-10-28Tokyo webmining 2017-10-28
Tokyo webmining 2017-10-28
 
Network Analysis with networkX : Real-World Example-2
Network Analysis with networkX : Real-World Example-2Network Analysis with networkX : Real-World Example-2
Network Analysis with networkX : Real-World Example-2
 
Icpp power ai-workshop 2018
Icpp power ai-workshop 2018Icpp power ai-workshop 2018
Icpp power ai-workshop 2018
 
Sea Amsterdam 2014 November 19
Sea Amsterdam 2014 November 19Sea Amsterdam 2014 November 19
Sea Amsterdam 2014 November 19
 
Scientific Computing with Python - NumPy | WeiYuan
Scientific Computing with Python - NumPy | WeiYuanScientific Computing with Python - NumPy | WeiYuan
Scientific Computing with Python - NumPy | WeiYuan
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpy
 
Code Generation
Code GenerationCode Generation
Code Generation
 
Designing linear algebra into Julia
Designing linear algebra into JuliaDesigning linear algebra into Julia
Designing linear algebra into Julia
 
Faster persistent data structures through hashing
Faster persistent data structures through hashingFaster persistent data structures through hashing
Faster persistent data structures through hashing
 
End-to-end Big Data Projects with Python - StampedeCon Big Data Conference 2017
End-to-end Big Data Projects with Python - StampedeCon Big Data Conference 2017End-to-end Big Data Projects with Python - StampedeCon Big Data Conference 2017
End-to-end Big Data Projects with Python - StampedeCon Big Data Conference 2017
 
Numpy Talk at SIAM
Numpy Talk at SIAMNumpy Talk at SIAM
Numpy Talk at SIAM
 
Performance
PerformancePerformance
Performance
 

Similar to Intermediate python ch1_slides

Python for Machine Learning(MatPlotLib).pptx
Python for Machine Learning(MatPlotLib).pptxPython for Machine Learning(MatPlotLib).pptx
Python for Machine Learning(MatPlotLib).pptx
Dr. Amanpreet Kaur
 
A Data Science Tutorial in Python
A Data Science Tutorial in PythonA Data Science Tutorial in Python
A Data Science Tutorial in Python
Ajay Ohri
 
PyTorch 튜토리얼 (Touch to PyTorch)
PyTorch 튜토리얼 (Touch to PyTorch)PyTorch 튜토리얼 (Touch to PyTorch)
PyTorch 튜토리얼 (Touch to PyTorch)
Hansol Kang
 
Python For Scientists
Python For ScientistsPython For Scientists
Python For Scientists
aeberspaecher
 
IAT334-Lab02-ArraysPImage.pptx
IAT334-Lab02-ArraysPImage.pptxIAT334-Lab02-ArraysPImage.pptx
IAT334-Lab02-ArraysPImage.pptx
ssuseraae9cd
 
Data visualization in Python
Data visualization in PythonData visualization in Python
Data visualization in Python
Marc Garcia
 
Matplotlib
MatplotlibMatplotlib
Matplotlib
Amir Shokri
 
Scipy 2011 Time Series Analysis in Python
Scipy 2011 Time Series Analysis in PythonScipy 2011 Time Series Analysis in Python
Scipy 2011 Time Series Analysis in Python
Wes McKinney
 
BDACA - Tutorial5
BDACA - Tutorial5BDACA - Tutorial5
Data Structures for Statistical Computing in Python
Data Structures for Statistical Computing in PythonData Structures for Statistical Computing in Python
Data Structures for Statistical Computing in Python
Wes McKinney
 
Python for Scientists
Python for ScientistsPython for Scientists
Python for Scientists
Andreas Dewes
 
Scientific Plotting in Python
Scientific Plotting in PythonScientific Plotting in Python
Scientific Plotting in Python
Jack Parmer
 
Introduction to Pylab and Matploitlib.
Introduction to Pylab and Matploitlib. Introduction to Pylab and Matploitlib.
Introduction to Pylab and Matploitlib.
yazad dumasia
 
Chaco Step-by-Step
Chaco Step-by-StepChaco Step-by-Step
Chaco Step-by-Step
Enthought, Inc.
 
2015 03-28-eb-final
2015 03-28-eb-final2015 03-28-eb-final
2015 03-28-eb-final
Christopher Wilson
 
A Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with PythonA Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with Python
Tariq Rashid
 
ch1_slides.pdf
ch1_slides.pdfch1_slides.pdf
ch1_slides.pdf
YuanlongZhang3
 
Python update in 2018 #ll2018jp
Python update in 2018 #ll2018jpPython update in 2018 #ll2018jp
Python update in 2018 #ll2018jp
cocodrips
 
Python tour
Python tourPython tour
Python tour
Tamer Abdul-Radi
 
Use the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docxUse the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docx
dickonsondorris
 

Similar to Intermediate python ch1_slides (20)

Python for Machine Learning(MatPlotLib).pptx
Python for Machine Learning(MatPlotLib).pptxPython for Machine Learning(MatPlotLib).pptx
Python for Machine Learning(MatPlotLib).pptx
 
A Data Science Tutorial in Python
A Data Science Tutorial in PythonA Data Science Tutorial in Python
A Data Science Tutorial in Python
 
PyTorch 튜토리얼 (Touch to PyTorch)
PyTorch 튜토리얼 (Touch to PyTorch)PyTorch 튜토리얼 (Touch to PyTorch)
PyTorch 튜토리얼 (Touch to PyTorch)
 
Python For Scientists
Python For ScientistsPython For Scientists
Python For Scientists
 
IAT334-Lab02-ArraysPImage.pptx
IAT334-Lab02-ArraysPImage.pptxIAT334-Lab02-ArraysPImage.pptx
IAT334-Lab02-ArraysPImage.pptx
 
Data visualization in Python
Data visualization in PythonData visualization in Python
Data visualization in Python
 
Matplotlib
MatplotlibMatplotlib
Matplotlib
 
Scipy 2011 Time Series Analysis in Python
Scipy 2011 Time Series Analysis in PythonScipy 2011 Time Series Analysis in Python
Scipy 2011 Time Series Analysis in Python
 
BDACA - Tutorial5
BDACA - Tutorial5BDACA - Tutorial5
BDACA - Tutorial5
 
Data Structures for Statistical Computing in Python
Data Structures for Statistical Computing in PythonData Structures for Statistical Computing in Python
Data Structures for Statistical Computing in Python
 
Python for Scientists
Python for ScientistsPython for Scientists
Python for Scientists
 
Scientific Plotting in Python
Scientific Plotting in PythonScientific Plotting in Python
Scientific Plotting in Python
 
Introduction to Pylab and Matploitlib.
Introduction to Pylab and Matploitlib. Introduction to Pylab and Matploitlib.
Introduction to Pylab and Matploitlib.
 
Chaco Step-by-Step
Chaco Step-by-StepChaco Step-by-Step
Chaco Step-by-Step
 
2015 03-28-eb-final
2015 03-28-eb-final2015 03-28-eb-final
2015 03-28-eb-final
 
A Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with PythonA Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with Python
 
ch1_slides.pdf
ch1_slides.pdfch1_slides.pdf
ch1_slides.pdf
 
Python update in 2018 #ll2018jp
Python update in 2018 #ll2018jpPython update in 2018 #ll2018jp
Python update in 2018 #ll2018jp
 
Python tour
Python tourPython tour
Python tour
 
Use the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docxUse the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docx
 

Recently uploaded

How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
TaghreedAltamimi
 
Top 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptxTop 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptx
devvsandy
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Envertis Software Solutions
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
Marcin Chrost
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 

Recently uploaded (20)

How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
 
Top 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptxTop 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptx
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 

Intermediate python ch1_slides

  • 1. INTERMEDIATE PYTHON FOR DATA SCIENCE Basic Plots 
 with Matplotlib
  • 2. Intermediate Python for Data Science !● Visualization " " "● Data Structures #● Control Structures $● Case Study
  • 3. Intermediate Python for Data Science Data Visualization ● Very important in Data Analysis ● Explore data ● Report insights
  • 4. Intermediate Python for Data Science Source: GapMinder, Wealth and Health of Nations
  • 5. Intermediate Python for Data Science Matplotlib In [1]: import matplotlib.pyplot as plt In [2]: year = [1950, 1970, 1990, 2010] In [3]: pop = [2.519, 3.692, 5.263, 6.972] In [4]: plt.plot(year, pop) In [5]: plt.show() x y
  • 6. Intermediate Python for Data Science Matplotlib year = [1950, 1970, 1990, 2010] pop = [2.519, 3.692, 5.263, 6.972]
  • 7. Intermediate Python for Data Science Sca er plot In [1]: import matplotlib.pyplot as plt In [2]: year = [1950, 1970, 1990, 2010] In [3]: pop = [2.519, 3.692, 5.263, 6.972] In [4]: plt.plot(year, pop) In [5]: plt.show()
  • 8. Intermediate Python for Data Science Sca er plot In [1]: import matplotlib.pyplot as plt In [2]: year = [1950, 1970, 1990, 2010] In [3]: pop = [2.519, 3.692, 5.263, 6.972] In [4]: plt. (year, pop) In [5]: plt.show() scatter
  • 9. INTERMEDIATE PYTHON FOR DATA SCIENCE Let’s practice!
  • 10. INTERMEDIATE PYTHON FOR DATA SCIENCE Histogram
  • 11. Intermediate Python for Data Science Histogram ● Explore dataset ● Get idea about distribution 0 1 2 3 4 5 6 0 2 4 6
  • 12. Intermediate Python for Data Science Matplotlib In [1]: import matplotlib.pyplot as plt Help on function hist in module matplotlib.pyplot: hist(x, bins=10, range=None, normed=False, weights=None,
 cumulative=False, bottom=None, histtype='bar', align='mid',
 orientation='vertical', rwidth=None, log=False, color=None,
 label=None, stacked=False, hold=None, data=None, **kwargs) Plot a histogram. Compute and draw the histogram of *x*. The return value is a tuple (*n*, *bins*, *patches*) or ([*n0*, *n1*, ...],
 *bins*, [*patches0*, *patches1*,...]) if the input contains
 multiple data. ... In [2]: help(plt.hist)
  • 13. Intermediate Python for Data Science Matplotlib example In [3]: values = [0,0.6,1.4,1.6,2.2,2.5,2.6,3.2,3.5,3.9,4.2,6] In [4]: plt.hist(values, bins = 3) In [5]: plt.show()
  • 14. Intermediate Python for Data Science Population Pyramid
  • 15. INTERMEDIATE PYTHON FOR DATA SCIENCE Let’s practice!
  • 16. INTERMEDIATE PYTHON FOR DATA SCIENCE Customization
  • 17. Intermediate Python for Data Science Data Visualization ● Many options ● Different plot types ● Many customizations ● Choice depends on ● Data ● Story you want to tell
  • 18. Intermediate Python for Data Science Basic Plot population.py import matplotlib.pyplot as plt year = [1950, 1951, 1952, ..., 2100] pop = [2.538, 2.57, 2.62, ..., 10.85] plt.plot(year, pop) plt.show() !
  • 19. Intermediate Python for Data Science Axis labels import matplotlib.pyplot as plt year = [1950, 1951, 1952, ..., 2100] pop = [2.538, 2.57, 2.62, ..., 10.85] plt.plot(year, pop) plt.show() population.py! plt.xlabel('Year') plt.ylabel('Population')
  • 20. Intermediate Python for Data Science Axis labels import matplotlib.pyplot as plt year = [1950, 1951, 1952, ..., 2100] pop = [2.538, 2.57, 2.62, ..., 10.85] plt.plot(year, pop) plt.show() population.py! plt.xlabel('Year') plt.ylabel('Population')
  • 21. Intermediate Python for Data Science Title import matplotlib.pyplot as plt year = [1950, 1951, 1952, ..., 2100] pop = [2.538, 2.57, 2.62, ..., 10.85] plt.plot(year, pop) plt.xlabel('Year') plt.ylabel('Population') plt.show() population.py! plt.title('World Population Projections')
  • 22. Intermediate Python for Data Science Title import matplotlib.pyplot as plt year = [1950, 1951, 1952, ..., 2100] pop = [2.538, 2.57, 2.62, ..., 10.85] plt.plot(year, pop) plt.xlabel('Year') plt.ylabel('Population') plt.show() population.py! plt.title('World Population Projections')
  • 23. Intermediate Python for Data Science Ticks import matplotlib.pyplot as plt year = [1950, 1951, 1952, ..., 2100] pop = [2.538, 2.57, 2.62, ..., 10.85] plt.plot(year, pop) plt.xlabel('Year') plt.ylabel('Population') plt.title('World Population Projections') plt.show() population.py! plt.yticks([0, 2, 4, 6, 8, 10])
  • 24. Intermediate Python for Data Science Ticks import matplotlib.pyplot as plt year = [1950, 1951, 1952, ..., 2100] pop = [2.538, 2.57, 2.62, ..., 10.85] plt.plot(year, pop) plt.xlabel('Year') plt.ylabel('Population') plt.title('World Population Projections') plt.show() population.py! plt.yticks([0, 2, 4, 6, 8, 10])
  • 25. Intermediate Python for Data Science Ticks (2) import matplotlib.pyplot as plt year = [1950, 1951, 1952, ..., 2100] pop = [2.538, 2.57, 2.62, ..., 10.85] plt.plot(year, pop) plt.xlabel('Year') plt.ylabel('Population') plt.title('World Population Projections') plt.yticks([0, 2, 4, 6, 8, 10], plt.show() population.py! ['0', '2B', '4B', '6B', '8B', '10B'])
  • 26. Intermediate Python for Data Science Ticks (2) import matplotlib.pyplot as plt year = [1950, 1951, 1952, ..., 2100] pop = [2.538, 2.57, 2.62, ..., 10.85] plt.plot(year, pop) plt.xlabel('Year') plt.ylabel('Population') plt.title('World Population Projections') plt.yticks([0, 2, 4, 6, 8, 10], plt.show() population.py! ['0', '2B', '4B', '6B', '8B', '10B'])
  • 27. Intermediate Python for Data Science Add historical data import matplotlib.pyplot as plt year = [1950, 1951, 1952, ..., 2100] pop = [2.538, 2.57, 2.62, ..., 10.85] plt.plot(year, pop) plt.xlabel('Year') plt.ylabel('Population') plt.title('World Population Projections') plt.yticks([0, 2, 4, 6, 8, 10],
 ['0', '2B', '4B', '6B', '8B', '10B']) plt.show() population.py! # Add more data year = [1800, 1850, 1900] + year pop = [1.0, 1.262, 1.650] + pop
  • 28. Intermediate Python for Data Science Add historical data import matplotlib.pyplot as plt year = [1950, 1951, 1952, ..., 2100] pop = [2.538, 2.57, 2.62, ..., 10.85] plt.plot(year, pop) plt.xlabel('Year') plt.ylabel('Population') plt.title('World Population Projections') plt.yticks([0, 2, 4, 6, 8, 10],
 ['0', '2B', '4B', '6B', '8B', '10B']) plt.show() population.py! # Add more data year = [1800, 1850, 1900] + year pop = [1.0, 1.262, 1.650] + pop
  • 29. Intermediate Python for Data Science Before vs A er
  • 30. INTERMEDIATE PYTHON FOR DATA SCIENCE Let’s practice!