Page 352 - Informatics_Practices_Fliipbook_Class12
P. 352
The method describe() which returns a DataFrame comprising the statistics- count, mean, standard
deviation, minimum, maximum, and quartiles, about each column in the DataFrame that storenumerical data.
By specifying include='all' as the keyword argument, the summary information includes count, unique,
top, and frequency statistics for each non-numeric column.
42. Which of the method of Pandas DataFame df can be used to perform the following tasks:
(i) Display statistical summary about a DataFrame.
(ii) Display first n records of a DataFrame.
(iii) Display last n records of a DataFrame.
(iv) Set a column as an index
(v) Distinct elements in a column.
(vi) Count of occurrences of each unique value in a column of the dataframe.
(vii) Drop a column or row from the DataFrame.
(viii) Rename one or more columns in a DataFrame
(ix) Writing a DataFrame object to a csv file.
(x) Organise the data in a DataFrame into groups, based on specific criteria, such as values stored in one or
more columns.
Ans: (i) df.describe()
(ii) df.head()
(iii) df.tail()
(iv) df.set_index()
(v) df.unique()
(vi) df.value_counts()
(vii) df.drop()
(viii) df.rename()
(ix) df.to_csv()
(x) df.groupby()
43. What is the default value of axis in Pandas DataFrame methods?
Ans. Default axis along which the operation is to be performed is set to 'index' or 0 which denotes that the operation
is to be applied column-wise across rows. Alternatively, we may apply the operation row-wise across columns by
setting the axis to 'columns' or 1.
44. Explain the Pandas method that allow us to concatenate a DataFrame with the another DataFrame.
Ans. Pandas method pd.concat() can be used to concatenate a DataFrame with another DataFrame. By default,
the method concatenates the two dataframes rows wise (axis = 0). However, we can also concatenate the
DataFrames columnwise by setting keyword argument axis = 1.
45. Determine the aggregate methods supported by Pandas Series for performing the following operations:
(i) To compute sum of values in a column or across specified axis in a DataFrame.
(ii) To compute average value of a column or across specified axis in a DataFrame.
(iii) To find the maximum value in a column or across specified axis in a DataFrame.
(iv) To find the minimum value in a column or across specified axis in a DataFrame
338 Touchpad Informatics Practices-XII

