Professional Documents
Culture Documents
Ansser Key
Ansser Key
Azamgarh
Time : 45 mins. Class Test-1 (XII IP) M.M. 10
Section –A
Q1. What is NumPy Array?
Ans: A NumPy array is simply a grid that contains values of the same/homogenous type. NumPy Arrays come in two
forms:
∑ 1-D(one dimensional) arrays known as Vectors(having single row/column only)
∑ Multidimensional arrays known as Matrices(can have multiple rows and columns)
Example 1D array Example 2D array
import numpy as np import numpy as np
list = [1,2,3,4] a1 = np.array([ [10,11,12,13] , [21,22,23,24] ])
a1=np.array(list)
Ans: output : [1 2 3 3 2 1]
Section –B
Q1-What do you understand by reshaping of a dataframe . Also ,name the methods which are used to do so.
Ans: Reshaping : changing the rows and columns, column and index labels along with the values.
pivot() and pivot_table()
Q2-State the difference between reindexing and renaming lables in a dataframe.Give examples.
Ans: Reindexing : Changing the order of rows in a dataframe. Example with reindex()
Renaming : Only changing the names of the existing index labels. Example with rename()
Q3-Write the python code to plot the given histogram with the following dataset:
(1)
(1)
(2)
(2)
Sarvodaya Public School
Azamgarh
(3)
table = OrderedDict((
("Product Name", ['Mixer','Dish Washer', 'Egg Beater', 'Mixer','Dish Washer']),
('Company',['Bajaj', 'Philips', 'Bajaj', 'Sony','Philips']),
('Price', [2000,6000,500,2500,6500])))
df1=pd.DataFrame(table)
print(df1)
p = df1.pivot_table(index='Company',columns='Product Name', values='Price')
print("\n\nDATA OF PIVOT")
print(p)