Git Product home page Git Product logo

ds-python-lists_dicts's Introduction

Day-2 (Python Data Structures)

SWBAT:

  • Describe the difference between primitive and non-primitive data structures
  • Perform data handling with Python lists by Storing, accessing and manipulating information in a list structure.
  • Perform data handling with Python dictionaries by Storing, accessing and manipulating information in a dictionary structure.
  • Demonstrate the ability to data from external sources into Python environment
  • Compare and constrast use cases for lists and dictionaries in python

Python primitive vs. non-primitive data structures (15 minutes)

Explain the idea behind non-primitive vs. primitive data structures independant of programming platforms. datastuct

Primitive Data Structures

A primitive data type is one that fits the base architecture of the underlying computer such as int, float, and pointer, and all of the variations, thereof such as char short long unsigned float double and etc, are primitive data type.

Primitive data are only single values, they have not special capabilities.

The examples of Primitive data types are given int, float, string, boolean etc.

The integer reals, logic data character data pointer and reference are primitive data structures data structure that normally are directly operated upon by machine level instructions are known as primitive structure and data type.

Non-primitive Data Structures

A non-primitive data type is something else such as an array structure or class is known as the non-primitive data type.

The data type that are derived from primary data types are known as non-primitive data type. The non-primitive data types are used to store the group of values.

Examples of non-primitive data type.

Array, lists, dictionaries, sets, stacks, queue etc.

(further details here) https://www.datacamp.com/community/tutorials/data-structures-python https://code.tutsplus.com/articles/advanced-python-data-structures--net-32748

Introduction to Collections in Python (5 minutes)

We have seen some simple Python types like numbers, strings and booleans. Now we will see how we can group multiple values together in a collection โ€“ like a list of numbers, or a dictionary which we can use to store and retrieve key-value pairs. Many useful collections are built-in types in Python as non-primitive data types and as data scientists you will encounter them quite often while reading data from external sources and collecting it in one of the data types explained later in this lesson.

http://python-textbok.readthedocs.io/en/1.0/Collections.html

Python Lists Lesson (25 min)

Click here to access the lesson

  • Lists and operations in Python
  • Creatig lists
  • List indexing , acessing elements
  • Lists slicing , creating new lists from exitsing
  • adding new elements / destructuve elements
  • Identifying unique elements by converting to sets
  • Length of lists with len()
  • A quick exercise for students to practice above operations

Python Lists Lab

Lists and Operations (20 min)

Click here to access the lab

Using lists for geo-visualisations using python folium library (20 min)

Click here to access the lab

Lists Discussion (10 minutes)

Answer any questions on lessons and labs on lists.

Python Dictionaries Lesson (20 min)

Click to acces the lesson

  • Intro to Python dict data structure
  • Dictionaries and Key-value pairs {k:v}
  • Creating dictionaries and adding elements
  • Recalling elements from dictionay
  • Dictionary of lists
  • lists of dictionaries

Python Dictionaries lab (25 minutes)

Practice dictionary creation, modification and operations highlighted in the lesson above. Click here to access the lab

Import from Excel into Python dictionaries (25 minutes)

Click here to access the lab

As data scientists, you will be routinely importing data from external sources including text files, xls, csv, XML, JASON and relational databases, to name a few. Following lesson given a brief insight into opening an xl file and reading data to be procssed in Python. We will use Pandas module in python which has built in methods to read and write different data file formats. Provide a quick introduction to Pandas. Further details on Pandas and its applications will be later covered in the course.

comparison

Click here to access the lesson

Python Dictionaries discussion and quick introduction to additional data (Sets, Tuples etc) structures with use cases (15 mins)

comparison

Extra reading

Compare and contrast lists, dictionaries, tuples and sets and describe the use cases for each of these. Consult following slides for examples https://www.slideshare.net/rampalliraj/learn-python-for-beginners-part2

Summary:

Today's lesson provided further insight into Python development environment with lists and dictionaries. We can now compare and contrast between use cases for both of these non primitive data types. We used data in lists to do some simple geographical visualisations using Python Folium library. The lesson highlighted how dictionaries can be used to store information as key: value pairs to ensure data integrity. As an extra lab, we also saw how to import data into pandas dataframe for processing.

ds-python-lists_dicts's People

Contributors

shakeelraja avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.