Page 75 - IPP-12-2024
P. 75

0    car                         Ford                         7000000
               1    AC                          Hitachi         5000
               2    Aircooler                   Symphony        12000
               3     Washing Machine     LG                            14000
               Result after Filtering DataFrame
                                        itemcat                       expenditure
               itemcat
               AC                      AC                               5000
               Aircooler              Aircooler        12000
               Washing Machine        Washing Machine  14000
               car                    car                               7000000

                                                                                        th
            Program 4: Write a program to print all the elements that are above the 75  percentile from the given
            series.
            Solution:

                import numpy as np
                series = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
                percentile_75 = np.percentile(series, 75)
                above_75th = [elem for elem in series if elem > percentile_75]
                print(above_75th)
            Output:
            [80, 90, 100]

            Program 5: Write a program to create a data frame for examination result and display row labels,
            column labels data types of each column and the dimensions.
            Solution:
             import pandas as pd

             dic={'Class':['I','II','III','IV','V','VI','VII','VIII','IX','X','XI',
             'XII'],


             'Pass_Percentage':[100,100,100,100,100,100,100,100,100,98.6,100,99]}
             result=pd.DataFrame(dic)

             print(result)
             print(result.dtypes)
             print('shape of the dataframe is::::')

             print(result.shape)
            Output:
               Class  Pass_Percentage
            0      I            100.0
            1     II            100.0
            2    III            100.0
            3     IV            100.0
            4      V            100.0
            5     VI            100.0
            6    VII            100.0
            7   VIII            100.0
            8     IX            100.0
            9      X             98.6
            10    XI            100.0
   70   71   72   73   74   75   76   77   78   79   80