GithubHelp home page GithubHelp logo

cmcs0157 / itp-u3-c2-football-dictionaries Goto Github PK

View Code? Open in Web Editor NEW

This project forked from maximedelson/itp-u3-c2-football-dictionaries

0.0 1.0 0.0 240 KB

Advanced collections practice.

Home Page: https://rmotr.com/data-science-python-course

License: Creative Commons Attribution Share Alike 4.0 International

Makefile 2.07% Python 97.93%

itp-u3-c2-football-dictionaries's Introduction

Football Dictionaries

Today's project will deal with two of our greatest passions: dictionaries and football ๐Ÿ˜‰.

This project is divided into 3 assignments, each one requires something different. But all these assignments will deal with the same initial data: a list of players structured as a "list of lists".

To put it in human: There's a big list that has players inside. But each player is represented as a list, with each position in the list being a different piece of information for the player.

Example:

SQUADS_DATA = [
  [
    "1",                                     # Number
    "GK",                                    # Position
    "Juan Botasso",                          # Name
    "(1908-10-23)23 October 1908 (aged 21)", # Date of Birth
    "",                                      # Caps
    "Quilmes",                               # Club
    "Argentina",                             # Country (Players Country)
    "Argentina",                             # Club Country
    "1930"                                   # Year
  ],
  [
    "9",
    "FW",
    "Roberto Cherro",
    "(1907-02-23)23 February 1907 (aged 23)",
    "",
    "Boca Juniors",
    "Argentina",
    "Argentina",
    "1930"
  ]
  # More Players...
]

Your job through this entire group project will be to transform these lists to Dictionaries.

Assignment 1 - Lists to Dicts

The first assignment just requires you to turn these players into dictionaries with the following structure:

{
    'number': ...,
    'position': ...,
    'name': ...,
    'date_of_birth': ...,
    'caps': ...,
    'club': ...,
    'country': ...,
    'club_country': ...,
    'year': ...,
}

Given our previous example, now our new list containing players as dictionaries would look like:

SQUADS_DATA = [
  {
    'number': "1",
    'position': "GK",
    'name': "Juan Botasso",
    'date_of_birth': "(1908-10-23)23 October 1908 (aged 21)",
    'caps': "",
    'club': "Quilmes",
    'country': "Argentina",
    'club_country': "Argentina",
    'year': "1930"
  },
  {
    'number': "9",
    'position': "FW",
    'name': "Roberto Cherro",
    'date_of_birth': "(1907-02-23)23 February 1907 (aged 23)",
    'caps': "",
    'club': "Boca Juniors",
    'country': "Argentina",
    'club_country': "Argentina",
    'year': "1930"
  }
  # More Players...
]

Assignment 2

This assignment is similar to the previous one, but instead of having just one big list with all the players, we're going to group them by position. Your result will look something like:

# Please note we're returning a dictionary instead of a list
{
  "GK": [{..player1..}, {..player2..}],
  "DF": [{..player1..}, {..player2..}],
  "MF": [{..player1..}, {..player2..}],
  "FW": [{..player1..}, {..player2..}],
}

Assignment 3

And finally this is really similar to the second assignment but we'll add one more level of nesting. This function will return the players grouped by country, and per each country, grouped by position. Example:

{
  "Argentina": {
    "GK": [{..player1..}, {..player2..}],
    "DF": [{..player1..}, {..player2..}],
    "MF": [{..player1..}, {..player2..}],
    "FW": [{..player1..}, {..player2..}],
  },
  "Brazil": {
    "GK": [{..player1..}, {..player2..}],
    "DF": [{..player1..}, {..player2..}],
    "MF": [{..player1..}, {..player2..}],
    "FW": [{..player1..}, {..player2..}],
  }
}

Walkthrough solution

We've got together with a few students to present a possible solution. Watch it on YouTube:

itp-u3-c2-football-dictionaries's People

Contributors

cmcs0157 avatar santiagobasulto avatar ivanzugnoni avatar jsymons avatar

Watchers

James Cloos 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.