Nested Data Structures and Nested Loops

Nested Data Structures and Nested Loops

A loop within a loop… within a loop. I have found that it can help a lot to break it down and pay attention to just one loop at a time as you build your way up to the nested loop structure.

I am in my second week of the part-time data science program at Flatiron School, and so far everything has been going great! I made the decision to pursue a career in data science after many years of deliberating over what career path would suit me best. I have a dual Bachelor’s degree in both Psychology and Philosophy, but until recently, I had yet to find a realm within those fields that I am particularly passionate about. Thanks to the Covid-19 pandemic and months of quarantine, I have finally been able to pursue my interests in technology, statistics, and coding at Flatiron. I love my instructors and my cohort of friendly peers, and I am finding that I have a good grasp on the material so far.

There is one thing that has thrown me for a loop though (pun definitely intended): nested loops in Python.

At the onset of this program, we were encouraged to blog about aspects of the material that we may find challenging, so as to help ourselves obtain a deeper understanding of it while also helping others to learn. Nested loops were tricky to me at first because of the fact that they are loops inside of other loops. I have found that it can help a lot to break it down and pay attention to just one loop at a time as you build your way up to the nested loop structure.

The work that I did to write this post also involved understanding of dictionaries in Python and list comprehension, two topics which also were a bit difficult at first. As with most obstacles, the more I’ve worked with it, the easier it has become. So with that in mind, here is some work with nested data in Python using nested loops.

I will start with some data that represents my family.

my_family = [

  { "family_name": "Tunnicliffe",
    "num_people": 4,
    "local": True,
    "city": "Bethpage, NY",
    "date_established": 2014,
    "names": ["Diane", "Steve", "Dylan", "Landon"],
    "number_of_children": 2,
    "children": [
      {
        "name": "Dylan",
        "age": 5,
        "favorite_color": "black",
        "nickname": "Dillybeans",
        "loves": "Super Mario",
      },
      {
        "name": "Landon",
        "age": 2,
        "favorite_color": "blue",
        "nickname": "Landybean",
        "loves": "trucks",
      }
    ]
  },
  { "family_name": "Agulnick",
    "num_people": 5,
    "local": False,
    "city": "Newton, MA",
    "date_established": 1987,
    "names": ["Ellen", "Mark", "Diane", "Joshua", "Allison"],
    "number_of_children": 3,
    "children": [
      {
        "name": "Diane",
        "age": 31,
        "favorite_color": "pink",
        "nickname": "Dini",
        "loves": "unicorns",
      },
      {
        "name": "Joshua",
        "age": 28,
        "favorite_color": "red",
        "nickname": "Joshie",
        "loves": "trains",
      },
      {
        "name": "Allison",
        "age": 26,
        "favorite_color": "purple",
        "nickname": "Alli",
        "loves": "candy",
      }
    ]
  }
]

for-loop data-science python3 list-comprehension flatiron-school

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

50 Data Science Jobs That Opened Just Last Week

Data Science and Analytics market evolves to adapt to the constantly changing economic and business environments. Our latest survey report suggests that as the overall Data Science and Analytics market evolves to adapt to the constantly changing economic and business environments, data scientists and AI practitioners should be aware of the skills and tools that the broader community is working on. A good grip in these skills will further help data science enthusiasts to get the best jobs that various industries in their data science functions are offering.

The List of Top 10 Data Science Lists; Data Science MOOCs with Substance

The List of Top 10 Lists in Data Science; Going Beyond Superficial: Data Science MOOCs with Substance; Introduction to Statistics for Data Science; Content-Based Recommendation System using Word Embeddings; How Natural Language Processing Is Changing Data Analytics. Also this week: The List of Top 10 Lists in Data Science; Going Beyond Superficial: Data Science MOOCs with Substance; Introduction to Statistics for Data Science

Applications Of Data Science On 3D Imagery Data

The agenda of the talk included an introduction to 3D data, its applications and case studies, 3D data alignment and more.

Data Science Course in Dallas

Become a data analysis expert using the R programming language in this [data science](https://360digitmg.com/usa/data-science-using-python-and-r-programming-in-dallas "data science") certification training in Dallas, TX. You will master data...

32 Data Sets to Uplift your Skills in Data Science | Data Sets

Need a data set to practice with? Data Science Dojo has created an archive of 32 data sets for you to use to practice and improve your skills as a data scientist.