Page 87 - Informatics_Practices_Fliipbook_Class12
P. 87

print("\nMaximum wind speed:", maxWindSpeed)

                    data = weatherDF.iloc[3:5, 3]
                    print('Wind speed data for the last two days:')
                    print(data)


                                                     Assessment


            A.  Multiple Choice Questions
               1.  Which of the following Pandas DataFrame method provides a summary of the statistics of a DataFrame, such as count,
                  mean, min, max, and quartiles?
                  a.  df.info()            b. df.describe()       c. df.dtypes()        d. df.summary()
               2.  Which of the following functions can be used to determine the count of the occurrence of each unique value in a specific
                  column of a DataFrame?
                  a.  df.count_values()  b. df.unique()           c. df.value_counts() d. df.describe()

               3.  Which of the following statements can be used to add a new column named 'ContactNum' to a DataFramedf?
                  a.  df.add_column('ContactNum', values)
                  b.  df.insert('ContactNum', column=values)
                  c.  df['ContactNum'] = values
                  d.  df.update('ContactNum', values)
               4.  Which of the following functions of DataFramedf can be used to drop Age column?
                  a.  df.drop('Age')                              b. df.remove_column('Age')
                  c.  df.drop_column('Age')                       d. df.delete('Age')

               5.  How can you concatenate two DataFrames df01 and df02 row-wise?
                  a.  dfConcatenated = pd.concat([df01, df02], axis=0)
                  b.  dfConcatenated = pd.concat([df01, df02], axis=1)
                  c.  dfConcatenated = pd.concat([df01, df02], join='inner')
                  d.  dfConcatenated = pd.concat([df01, df02], join='outer')
               6.  Which of the following functions of DataFrane df can be used to rename a column named OldCol to NewCol?

                  a.  df.rename_column('OldCol', 'NewCol')
                  b.  df.rename(columns={'OldCol': 'NewCol'})
                  c.  df.replace_column('OldCol', 'NewCol')
                  d.  df.modify_column('OldCol', 'NewCol')
               7.  Which of the following is not an aggregate function supported by pandas DataFrame df?
                  a.  df.sum()             b. df.average()        c. df.max()           d. df.mean()

            B.  State whether the following statements are True or False:
               1.  Aggregation functions such as sum(), min(), max(), and mean() can be applied on a Pandas DataFrame
                  to calculate sum total, minimum, maximum, and average of values for each column.         _________
               2.  To add a new column to a Pandas DataFrame, we can use the syntax: df['new_column'] = values   _________
               3.  The pd.concat() function is used to concatenate two Pandas DataFrames only row-wise.    _________
               4.  The value_counts() method of Pandas DataFrame returns the number of unique values in a
                  given column.                                                                            _________
               5.  To rename columns in a Pandas DataFrame, use the rename() method with a dictionary comprising
                  the old and new column names.                                                            _________
               6.  The to_csv() method may be used to read a Pandas DataFrame from a CSV file.             _________


                                                                             Data Handling using Pandas DataFrame  73
   82   83   84   85   86   87   88   89   90   91   92