Page 77 - Informatics_Practices_Fliipbook_Class12
P. 77

output:
                 Category
                 Food         450
                 Household     80
                 Hygiene      370
                 Name: Total Price, dtype: int64
            Execution of
                   groceryGroupedDF['Total Price'].sum()

            in the Pandas tutor yields the following visualization:

                                            groceryGroupedDF['Total Price'].sum()
                                             Series                               Series
                                         0   40                   Category
                                         1   300                  Food              450
                                         2   40                   Household          80
                                         3   70                   Hygiene           370
                                         4   80
                                         5   160

                                         6   60
                                         7   150
            Sometimes, it is convinient to examine the results of applying more than one operations. This is achieved by applying
            the function agg and passing the list of operations to be carried out on the groups of data as an argument to the
            function agg. Below, we apply the sum and count operations by applying the function agg(['sum', 'count'])
            to groceryGroupedDF['Total Price'].

             >>> groceryGroupedDF['Total Price'].agg(['sum', 'count'])
            output:
                               sum      count
                  Category
                      Food   450            4
                 Household    80            1
                    Hygiene  370            3
            Execution of

                   groceryGroupedDF['Total Price'].agg(['sum', 'count'])
            in the Pandas tutor yields the following visualization:

                                 groceryGroupedDF['Total Price'].agg(['sum', 'count'])

                                        Series                                Sum   count
                                    0    40                   Category
                                    1    300                  Food             450      4
                                    2    40                   Household         80      1
                                    3    70                   Hygiene          370      3
                                    4    80
                                    5    160
                                    6    60

                                    7    150



                                                                             Data Handling using Pandas DataFrame  63
   72   73   74   75   76   77   78   79   80   81   82