Giter Club home page Giter Club logo

class-5-advanced-collections's Introduction

Class 5: Advanced collections practice

Spreadsheet with data

Step 1: String to List

The first step is to parse the raw string into a list containing products (as lists). It'll end up being a nested collections (a list of lists).

Step 2: Group by customers

Group invoices per customer. Your final result will look something like:

{
    '17850': [  # Customer ID
        [
            '536365',
            '85123A',
            'WHITE HANGING HEART T-LIGHT HOLDER',
            '6',
            '12/1/10 08:26',
            '2.55',
            '17850',
            'United Kingdom'
        ],
        [
            "536365",
            "71053",
            "WHITE METAL LANTERN",
            "6",
            "12/1/10 08:26",
            "3.39",
            "17850",
            "United Kingdom"
        ]
    ]
}

Step 3: Group by customers and invoice number

Group invoices by customer and invoice number. Your final result will look something like:

{
    '17850': {  # Customer ID
        '536365': [  # Invoice ID
            [
                "536365",
                "85123A",
                "WHITE HANGING HEART T-LIGHT HOLDER",
                "6",
                "12/1/10 08:26",
                "2.55",
                "17850",
                "United Kingdom"
            ],
            ...
            [
                "536365",
                "21730",
                "GLASS STAR FROSTED T-LIGHT HOLDER",
                "6",
                "12/1/10 08:26",
                "4.25",
                "17850",
                "United Kingdom"
            ]
        ],
        '536366': [  # Invoice ID
            [
                "536366",
                "22633",
                "HAND WARMER UNION JACK",
                "6",
                "12/1/10 08:28",
                "1.85",
                "17850",
                "United Kingdom"
            ],
            [
                "536366",
                "22632",
                "HAND WARMER RED POLKA DOT",
                "6",
                "12/1/10 08:28",
                "1.85",
                "17850",
                "United Kingdom"
            ]
        ]
    }
}

Step 4: Calculate total per invoice per customer

Calculate each invoice's total and keep them also grouped by customer.

image

Expected result will look:

{
    '17850': {  # Customer ID
        '536365': 139.12,  # Total for Invoice ID #536365
        '536366': 22.20,
        '536372': 22.20,
        '536373': 15.30,
    },
    '13047': {
        '536367': 278.73,
        '536368': 70.05,
        '536369': 17.85,
    },
    '12583': {
        '536370': 855.86
    },
    '13748': {
        '536371': 204
    }
}

class-5-advanced-collections's People

Contributors

santiagobasulto avatar

Watchers

James Cloos avatar Nick Van Kuren 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.