|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "code", |
5 | | - "execution_count": 63, |
| 5 | + "execution_count": 74, |
6 | 6 | "id": "d69d493a-0716-47e7-bc80-0ef36753fdf8", |
7 | 7 | "metadata": {}, |
8 | 8 | "outputs": [], |
|
54 | 54 | }, |
55 | 55 | { |
56 | 56 | "cell_type": "code", |
57 | | - "execution_count": 64, |
| 57 | + "execution_count": 75, |
58 | 58 | "id": "7302bac8-3643-4701-a1af-ea028dc8af38", |
59 | 59 | "metadata": {}, |
60 | 60 | "outputs": [], |
|
80 | 80 | }, |
81 | 81 | { |
82 | 82 | "cell_type": "code", |
83 | | - "execution_count": 65, |
| 83 | + "execution_count": 76, |
84 | 84 | "id": "d93c4011-0731-4992-9863-c198d570e18e", |
85 | 85 | "metadata": {}, |
86 | 86 | "outputs": [ |
|
302 | 302 | }, |
303 | 303 | { |
304 | 304 | "cell_type": "code", |
305 | | - "execution_count": 66, |
| 305 | + "execution_count": 77, |
306 | 306 | "id": "5ed00545-9d1e-4521-9d44-c6da89d5e4e5", |
307 | 307 | "metadata": {}, |
308 | 308 | "outputs": [ |
|
544 | 544 | }, |
545 | 545 | { |
546 | 546 | "cell_type": "code", |
547 | | - "execution_count": 67, |
| 547 | + "execution_count": 78, |
548 | 548 | "id": "9c93b32b-443e-4321-80fa-3d46fa8a0b1d", |
549 | 549 | "metadata": {}, |
550 | 550 | "outputs": [ |
|
570 | 570 | " <tr style=\"text-align: right;\">\n", |
571 | 571 | " <th></th>\n", |
572 | 572 | " <th></th>\n", |
573 | | - " <th>Date</th>\n", |
| 573 | + " <th></th>\n", |
574 | 574 | " <th>Item</th>\n", |
575 | 575 | " <th>Brand</th>\n", |
576 | 576 | " <th>Price</th>\n", |
|
580 | 580 | " <tr>\n", |
581 | 581 | " <th>OrderNo</th>\n", |
582 | 582 | " <th>Empno</th>\n", |
583 | | - " <th></th>\n", |
| 583 | + " <th>Date</th>\n", |
584 | 584 | " <th></th>\n", |
585 | 585 | " <th></th>\n", |
586 | 586 | " <th></th>\n", |
|
592 | 592 | " <tr>\n", |
593 | 593 | " <th>4626232</th>\n", |
594 | 594 | " <th>9003</th>\n", |
595 | | - " <td>2021-08-042021-08-04</td>\n", |
| 595 | + " <th>2021-08-04</th>\n", |
596 | 596 | " <td>SocksJeans</td>\n", |
597 | 597 | " <td>VansQuiksilver</td>\n", |
598 | 598 | " <td>97.0</td>\n", |
|
602 | 602 | " <tr>\n", |
603 | 603 | " <th>4626377</th>\n", |
604 | 604 | " <th>9003</th>\n", |
605 | | - " <td>2021-08-052021-08-05</td>\n", |
| 605 | + " <th>2021-08-05</th>\n", |
606 | 606 | " <td>HoodyCargo Shorts</td>\n", |
607 | 607 | " <td>AnimalAnimal</td>\n", |
608 | 608 | " <td>82.0</td>\n", |
|
612 | 612 | " <tr>\n", |
613 | 613 | " <th>4626412</th>\n", |
614 | 614 | " <th>9004</th>\n", |
615 | | - " <td>2021-08-05</td>\n", |
| 615 | + " <th>2021-08-05</th>\n", |
616 | 616 | " <td>Shirt</td>\n", |
617 | 617 | " <td>Volcom</td>\n", |
618 | 618 | " <td>78.0</td>\n", |
|
622 | 622 | " <tr>\n", |
623 | 623 | " <th>4626490</th>\n", |
624 | 624 | " <th>9004</th>\n", |
625 | | - " <td>2021-08-062021-08-06</td>\n", |
| 625 | + " <th>2021-08-06</th>\n", |
626 | 626 | " <td>Cargo ShortsSweater</td>\n", |
627 | 627 | " <td>BillabongDickies</td>\n", |
628 | 628 | " <td>110.0</td>\n", |
|
632 | 632 | " <tr>\n", |
633 | 633 | " <th>9423517</th>\n", |
634 | 634 | " <th>9001</th>\n", |
635 | | - " <td>2021-08-042021-08-04</td>\n", |
| 635 | + " <th>2021-08-04</th>\n", |
636 | 636 | " <td>JeansJacket</td>\n", |
637 | 637 | " <td>Rip CurlThe North Face</td>\n", |
638 | 638 | " <td>199.0</td>\n", |
|
642 | 642 | " <tr>\n", |
643 | 643 | " <th>9423534</th>\n", |
644 | 644 | " <th>9001</th>\n", |
645 | | - " <td>2021-08-042021-08-04</td>\n", |
| 645 | + " <th>2021-08-04</th>\n", |
646 | 646 | " <td>SocksSocks</td>\n", |
647 | 647 | " <td>DCQuiksilver</td>\n", |
648 | 648 | " <td>22.0</td>\n", |
|
652 | 652 | " <tr>\n", |
653 | 653 | " <th>9423679</th>\n", |
654 | 654 | " <th>9002</th>\n", |
655 | | - " <td>2021-08-05</td>\n", |
| 655 | + " <th>2021-08-05</th>\n", |
656 | 656 | " <td>T-shirt</td>\n", |
657 | 657 | " <td>Patagonia</td>\n", |
658 | 658 | " <td>35.0</td>\n", |
|
662 | 662 | " <tr>\n", |
663 | 663 | " <th>9423783</th>\n", |
664 | 664 | " <th>9002</th>\n", |
665 | | - " <td>2021-08-062021-08-06</td>\n", |
| 665 | + " <th>2021-08-06</th>\n", |
666 | 666 | " <td>Boxer ShortsShorts</td>\n", |
667 | 667 | " <td>SuperdryGlobe</td>\n", |
668 | 668 | " <td>56.0</td>\n", |
|
674 | 674 | "</div>" |
675 | 675 | ], |
676 | 676 | "text/plain": [ |
677 | | - " Date Item \\\n", |
678 | | - "OrderNo Empno \n", |
679 | | - "4626232 9003 2021-08-042021-08-04 SocksJeans \n", |
680 | | - "4626377 9003 2021-08-052021-08-05 HoodyCargo Shorts \n", |
681 | | - "4626412 9004 2021-08-05 Shirt \n", |
682 | | - "4626490 9004 2021-08-062021-08-06 Cargo ShortsSweater \n", |
683 | | - "9423517 9001 2021-08-042021-08-04 JeansJacket \n", |
684 | | - "9423534 9001 2021-08-042021-08-04 SocksSocks \n", |
685 | | - "9423679 9002 2021-08-05 T-shirt \n", |
686 | | - "9423783 9002 2021-08-062021-08-06 Boxer ShortsShorts \n", |
| 677 | + " Item Brand Price \\\n", |
| 678 | + "OrderNo Empno Date \n", |
| 679 | + "4626232 9003 2021-08-04 SocksJeans VansQuiksilver 97.0 \n", |
| 680 | + "4626377 9003 2021-08-05 HoodyCargo Shorts AnimalAnimal 82.0 \n", |
| 681 | + "4626412 9004 2021-08-05 Shirt Volcom 78.0 \n", |
| 682 | + "4626490 9004 2021-08-06 Cargo ShortsSweater BillabongDickies 110.0 \n", |
| 683 | + "9423517 9001 2021-08-04 JeansJacket Rip CurlThe North Face 199.0 \n", |
| 684 | + "9423534 9001 2021-08-04 SocksSocks DCQuiksilver 22.0 \n", |
| 685 | + "9423679 9002 2021-08-05 T-shirt Patagonia 35.0 \n", |
| 686 | + "9423783 9002 2021-08-06 Boxer ShortsShorts SuperdryGlobe 56.0 \n", |
687 | 687 | "\n", |
688 | | - " Brand Price Quantity Total \n", |
689 | | - "OrderNo Empno \n", |
690 | | - "4626232 9003 VansQuiksilver 97.0 2 97.0 \n", |
691 | | - "4626377 9003 AnimalAnimal 82.0 2 82.0 \n", |
692 | | - "4626412 9004 Volcom 78.0 1 78.0 \n", |
693 | | - "4626490 9004 BillabongDickies 110.0 2 110.0 \n", |
694 | | - "9423517 9001 Rip CurlThe North Face 199.0 2 199.0 \n", |
695 | | - "9423534 9001 DCQuiksilver 22.0 4 44.0 \n", |
696 | | - "9423679 9002 Patagonia 35.0 1 35.0 \n", |
697 | | - "9423783 9002 SuperdryGlobe 56.0 3 86.0 " |
| 688 | + " Quantity Total \n", |
| 689 | + "OrderNo Empno Date \n", |
| 690 | + "4626232 9003 2021-08-04 2 97.0 \n", |
| 691 | + "4626377 9003 2021-08-05 2 82.0 \n", |
| 692 | + "4626412 9004 2021-08-05 1 78.0 \n", |
| 693 | + "4626490 9004 2021-08-06 2 110.0 \n", |
| 694 | + "9423517 9001 2021-08-04 2 199.0 \n", |
| 695 | + "9423534 9001 2021-08-04 4 44.0 \n", |
| 696 | + "9423679 9002 2021-08-05 1 35.0 \n", |
| 697 | + "9423783 9002 2021-08-06 3 86.0 " |
698 | 698 | ] |
699 | 699 | }, |
700 | 700 | "metadata": {}, |
|
704 | 704 | "source": [ |
705 | 705 | "# A new DataFrame grouping by Order can be created to sum the total for each order using `groupby`\n", |
706 | 706 | "\n", |
707 | | - "df_order_totals = df_sales.groupby(['OrderNo', 'Empno']).sum()\n", |
| 707 | + "df_order_totals = df_sales.groupby(['OrderNo', 'Empno', 'Date']).sum()\n", |
708 | 708 | "\n", |
709 | 709 | "display(df_order_totals)" |
710 | 710 | ] |
|
0 commit comments