Class 12 IP Practice Assignment Series 12

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Write following MCQ Question Answer in your Notebook datewise.

Series-11
Revision Practice MCQ Unsolved Questions 17-09-2021
Class 12
Topic- Pandas dataframe pivoting
Subject IP

df-dataframe
name year item sales
ram 2015 tv 2
mohan 2015 tv 1
ram 2015 radio 4
mohan 2015 radio 5
ram 2016 tv 1
mohan 2016 tv 5
ram 2016 radio 3
mohan 2016 radio 5

import pandas as pd
import numpy as np
Q1. Which is a summarising technique to rearrange the columns and rows in a report so as to view data
from different angles?
a. Data pivoting
b. Data grouping

Q2. Which is used to show cross table format layout of our dataframe?
a. Sorting b. Pivoting

Q3. Select the correct syntax of pivot_table() function of python pandas.


a.
pivot_table (index = column name , columns = column name, values = numerical column name, aggfunc = operation)
b.
pivottable (index = column name , columns = column name, values = numerical column name, aggfunc = operation)

Q4. To create above dataframe df, so select correct python code for this:-
a.
df= pd.DataFrame(
{
‘name’ : [‘ram’, ‘mohan’, ‘ram’, ‘mohan’, ‘ram’, ‘mohan’, ‘ram’, ‘mohan’],
‘year’ : [2015, 2015, 2015, 2015, 2016, 2016, 2016, 2016 ],
‘item’ : [‘tv’, ‘tv’, ‘radio’, ‘radio’, ‘tv’, ‘tv’, ‘radio’, ‘radio’ ],
‘sales’ : [2, 1, 4, 5, 1, 5, 3, 5 ]
}

)
b.
df= pd.dataframe(
{
‘name’ : [‘ram’, ‘mohan’, ‘ram’, ‘mohan’, ‘ram’, ‘mohan’, ‘ram’, ‘mohan’],
‘year’ : [2015, 2015, 2015, 2015, 2016, 2016, 2016, 2016 ],
‘item’ : [‘tv’, ‘tv’, ‘radio’, ‘radio’, ‘tv’, ‘tv’, ‘radio’, ‘radio’ ],
‘sales’ : [2, 1, 4, 5, 1, 5, 3, 5 ]
}

Q5. To display year values in columns and To display name in rows with the help of pivot table.
To display sum all the sales values with the help of pivot table, so select python code for this:-
Year 2015 2016
name
mohan 6 10
ram 6 4
a.
print(df.pivot_table(index='name',columns='year',values='sales',aggfunc=np.max))
b.
print(df.pivot_table(index='name',columns='year',values='sales',aggfunc=np.sum))

Q6. To display year values in columns and To display name in rows with the help of pivot table.
To display maximum sales value with the help of pivot table, so select python code for this:-
Year 2015 2016
name
mohan 5 5
ram 4 3
a.
print(df.pivot_table(index='name',columns='year',values='sales',aggfunc=np.max))
b.
print(df.pivot_table(index='name',columns='year',values='sales',aggfunc=np.sum))

Q7. To display year values in columns and To display name in rows with the help of pivot table.
To display minimum sales value with the help of pivot table, so select python code for this:-
Year 2015 2016
Name
Mohan 1 5
Ram 2 1
a.
print(df.pivot_table(index='name',columns='year',values='sales',aggfunc=np.min))
b.
print(df.pivot_table(index='name',columns='year',values='sales',aggfunc=np.max))

Q8. To display year values in columns and To display name in rows with the help of pivot table.
To display average or mean sales value with the help of pivot table, so select python code for this:-
Year 2015 2016
name
mohan 3 5
ram 3 2
a.
print(df.pivot_table(index='name',columns='year',values='sales', aggfunc=np.mean))
b.
print(df.pivot_table(index='name',columns='year',values='sales', aggfunc=np.min))

Q9. To display names in columns and To display year values in rows with the help of pivot table.
To display sum sales value with the help of pivot table, so select python code for this:-
name mohan ram
Year
2015 6 10
2016 6 4
a.
print(df.pivot_table(index='year',columns='name',values='sales',aggfunc=np.max))
b.
print(df.pivot_table(index='year',columns='name',values='sales',aggfunc=np.sum))

Q10. To display names in columns and To display year values in rows with the help of pivot table.
To display max sales value with the help of pivot table, so select python code for this:-
name mohan ram
Year
2015 5 4
2016 5 3
a.
print(df.pivot_table(index='year',columns='name',values='sales',aggfunc=np.max))
b.
print(df.pivot_table(index='year',columns='name',values='sales',aggfunc=np.sum))

Q11. To display names in columns and To display year values in rows with the help of pivot table.
To display minimum sales value with the help of pivot table, so select python code for this:-
name mohan ram
Year
2015 1 2
2016 5 1
a.
print(df.pivot_table(index='year',columns='name',values='sales',aggfunc=np.min))
b.
print(df.pivot_table(index='year',columns='name',values='sales',aggfunc=np.max))

Q12. To display names in columns and To display year values in rows with the help of pivot table.
To display average/means sales value with the help of pivot table, so select python code for this:-
name mohan ram
Year
2015 1 2
2016 5 1
a.
print(df.pivot_table(index='year',columns='name',values='sales',aggfunc=np.mean))
b.
print(df.pivot_table(index='year',columns='name',values='sales',aggfunc=np.min))

Previous MCQ Question pdf file

Date Pdf file link


06-09-2021 Class 12 IP Practice Assignment Series 1
07-09-2021 Class 12 IP Practice Assignment Series 2
08-09-2021 Class 12 IP Practice Assignment Series 3
09-09-2021 Class 12 IP Practice Assignment Series 4
10-09-2021 Class 12 IP Practice Assignment Series 5
11-09-2021 Class 12 IP Practice Assignment Series 6
12-09-2021 Class 12 IP Practice Assignment Series 7
13-09-2021 Class 12 IP Practice Assignment Series 8
14-09-2021 Class 12 IP Practice Assignment Series 9
15-09-2021 Class 12 IP Practice Assignment Series 10
16-09-2021 Class 12 IP Practice Assignment Series 11

You might also like