Data Wrangling
Week 2
Dr. Ferdin Joe John Joseph
Faculty of Information Technology
Thai – Nichi Institute of Technology, Bangkok
Today’s Lesson
• Basics of Python
• Data Types
• Variables
• Operators and Operands
• Lists
• Demonstration
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Basics of Python
• Python is available in version 2 and 3
• Version 3 is highly recommended
• Version 2 is used to run some old frameworks
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Basics of Python
• Development started in the 1980’s by Guido van Rossum.
• Only became popular in the last decade or so.
• Interpreted, very-high-level programming language.
• Supports a multitude of programming paradigms.
• OOP, functional, procedural, logic, structured, etc.
• General purpose.
• Very comprehensive standard library includes numeric modules,
crypto services, OS interfaces, networking modules, GUI support,
development tools, etc.
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Features of Python
• Easy to learn.
• Supports quick development.
• Cross-platform.
• Open Source.
• Extensible.
• Embeddable.
• Large standard library and active community.
• Useful for a wide variety of applications.
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Getting Started
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Recommended way
• Use Miniconda
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Miniconda Installation
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Miniconda Installation
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Miniconda Installation
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Miniconda Installation
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Miniconda Installation
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Miniconda Installation
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Miniconda Installation
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Miniconda Installation
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Miniconda Installation
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Jupyter Lab Installation
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Jupyter Lab Installation
• Enter the following in the command prompt
conda install –c conda-forge jupyterlab
Respond ‘y’ when prompted
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Jupyter Lab – Getting Started
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Jupyter Lab – Getting Started
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Jupyter Lab
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Jupyter Lab
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Hello World
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Python - Datatype
• All datatypes are supported
• No need to mention integer of string
• Flexible in defining variable
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Python - Datatype
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Python - Datatype
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Python – Operations and operands
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Python – Operations and operands
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Python – Operations and operands
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Python – Operations and operands
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Python – Operators and Operands
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Variables: Numeric Type
• The subtypes are int, long, float and complex.
• Mixed arithmetic is supported, with the “narrower” type widened to
that of the other.
• The same rule is used for mixed comparisons.
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Variables: Numeric Type
• int: equivalent to Java’s long int in 2.x but unlimited in 3.x.
• float: equivalent to Java’s doubles.
• long: unlimited in 2.x and unavailable in 3.x.
• Complex: Complex numbers
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Numeric Type
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Variables: Sequence Type
• There are seven sequence subtypes: strings, Unicode strings, lists,
tuples, bytearrays, buffers, and xrange objects.
• The most commonly used sequence data types are strings, lists, and
tuples. The xrange data type finds common use in the construction of
enumeration-controlled loops. The others are used less commonly.
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Sequence Type: Strings
• Created by simply enclosing characters in either single- or double-
quotes.
• It’s enough to simply assign the string to a variable. Strings are
immutable.
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Strings
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Lists
• Arrays in Python
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Lists
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Lists
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Sequence operations
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Sequence operations
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Sequence operations
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Exercise
• Practice all the codes in Google Colab
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
Lesson for Next Week
• Dictionaries
• Control Statements
• Demonstration
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok

Data wrangling week2

  • 1.
    Data Wrangling Week 2 Dr.Ferdin Joe John Joseph Faculty of Information Technology Thai – Nichi Institute of Technology, Bangkok
  • 2.
    Today’s Lesson • Basicsof Python • Data Types • Variables • Operators and Operands • Lists • Demonstration Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 3.
    Basics of Python •Python is available in version 2 and 3 • Version 3 is highly recommended • Version 2 is used to run some old frameworks Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 4.
    Basics of Python •Development started in the 1980’s by Guido van Rossum. • Only became popular in the last decade or so. • Interpreted, very-high-level programming language. • Supports a multitude of programming paradigms. • OOP, functional, procedural, logic, structured, etc. • General purpose. • Very comprehensive standard library includes numeric modules, crypto services, OS interfaces, networking modules, GUI support, development tools, etc. Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 5.
    Features of Python •Easy to learn. • Supports quick development. • Cross-platform. • Open Source. • Extensible. • Embeddable. • Large standard library and active community. • Useful for a wide variety of applications. Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 6.
    Getting Started Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 7.
    Recommended way • UseMiniconda Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 8.
    Miniconda Installation Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 9.
    Miniconda Installation Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 10.
    Miniconda Installation Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 11.
    Miniconda Installation Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 12.
    Miniconda Installation Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 13.
    Miniconda Installation Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 14.
    Miniconda Installation Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 15.
    Miniconda Installation Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 16.
    Miniconda Installation Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 17.
    Jupyter Lab Installation Facultyof Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 18.
    Jupyter Lab Installation •Enter the following in the command prompt conda install –c conda-forge jupyterlab Respond ‘y’ when prompted Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 19.
    Jupyter Lab –Getting Started Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 20.
    Jupyter Lab –Getting Started Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 21.
    Jupyter Lab Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 22.
    Jupyter Lab Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 23.
    Hello World Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 24.
    Python - Datatype •All datatypes are supported • No need to mention integer of string • Flexible in defining variable Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 25.
    Python - Datatype Facultyof Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 26.
    Python - Datatype Facultyof Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 27.
    Python – Operationsand operands Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 28.
    Python – Operationsand operands Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 29.
    Python – Operationsand operands Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 30.
    Python – Operationsand operands Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 31.
    Python – Operatorsand Operands Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 32.
    Variables: Numeric Type •The subtypes are int, long, float and complex. • Mixed arithmetic is supported, with the “narrower” type widened to that of the other. • The same rule is used for mixed comparisons. Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 33.
    Variables: Numeric Type •int: equivalent to Java’s long int in 2.x but unlimited in 3.x. • float: equivalent to Java’s doubles. • long: unlimited in 2.x and unavailable in 3.x. • Complex: Complex numbers Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 34.
    Numeric Type Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 35.
    Variables: Sequence Type •There are seven sequence subtypes: strings, Unicode strings, lists, tuples, bytearrays, buffers, and xrange objects. • The most commonly used sequence data types are strings, lists, and tuples. The xrange data type finds common use in the construction of enumeration-controlled loops. The others are used less commonly. Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 36.
    Sequence Type: Strings •Created by simply enclosing characters in either single- or double- quotes. • It’s enough to simply assign the string to a variable. Strings are immutable. Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 37.
    Strings Faculty of InformationTechnology, Thai - Nichi Institute of Technology, Bangkok
  • 38.
    Lists • Arrays inPython Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 39.
    Lists Faculty of InformationTechnology, Thai - Nichi Institute of Technology, Bangkok
  • 40.
    Lists Faculty of InformationTechnology, Thai - Nichi Institute of Technology, Bangkok
  • 41.
    Sequence operations Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 42.
    Sequence operations Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 43.
    Sequence operations Faculty ofInformation Technology, Thai - Nichi Institute of Technology, Bangkok
  • 44.
    Exercise • Practice allthe codes in Google Colab Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok
  • 45.
    Lesson for NextWeek • Dictionaries • Control Statements • Demonstration Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok