Page 83 - Informatics_Practices_Fliipbook_Class12
P. 83

Determine the output of the following statements:
                  (i)  print(df.ndim)
                  (ii)  print(df.shape)
                  (iii)  print(df.index)
                  (iv)  print(df.columns)
                  (v)  print(df.head(5))
                  (vi)  print(df.tail(2))
                  (vii)  print(df.iloc[2])
                  (viii) print(df.loc[1,'Name'])
                  (ix)  print(df.set_index('Name'))
                  (x)  print(df[df['Age'] > 28])
                  (xi)  print(df[df['Height'] > 28])
             Ans.  (i)  2
                  (ii)  (4, 5)

                  (iii)  RangeIndex(start=0, stop=4, step=1)
                  (iv)   Index(['Name', 'Age', 'Gender', 'Height', 'Weight'], dtype='object')
                  (V)      Name          Age           Gender        Height         Weight

                      0   Rohan          25            M             175            70
                      1   Jasmine        30            F             160            55
                      2   Mohit          28            M             180            80
                      3   Anshika        32            F             165            60
                  (vi)     Name          Age           Gender        Height         Weight
                      2   Mohit          28            M             180            80
                      3   Anshika        32            F             165            60
                  (vii) Name      Mohit
                      Age         28
                      Gender      M
                      Height      180
                      Weight      80
                      Name: 2, dtype: object
                  (viii) 'Jasmine'
                  (ix) Name       Age           Gender        Height         Weight
                      Rohan       25            M             175            70
                      Jasmine     30            F             160            55

                      Mohit       28            M             180            80
                      Anshika    32             F             165            60
                  (x)       Name          Age          Gender         Height         Weight

                      1    Jasmine        30            F             160            55
                      3    Anshika        32            F             165            60
                  (xi)      Name         Age           Gender        Height         Weight

                      0    Rohan         25            M             175            70
                      1    Jasmine       30            F             160            55
                      2    Mohit         28            M             180            80
                      3    Anshika       32            F             165            60

                                                                             Data Handling using Pandas DataFrame  69
   78   79   80   81   82   83   84   85   86   87   88