Professional Documents
Culture Documents
Class 12 IP Practice Assignment Series 10
Class 12 IP Practice Assignment Series 10
Class 12 IP Practice Assignment Series 10
Series-10
Revision Practice MCQ Unsolved Questions 15-09-2021
Class 12
Topic- Pandas dataframe sorting
Subject IP
Q1. Select the correct, Ascending sorting example:
a. z to a or 100 to 1 b. a to z or 1 to 100
Q6. To sort name wise, in ascending order of following df dataframe, so select correct python code for
this:-
df-dataframe df-dataframe
name year item sales name year item sales
ram 2015 tv 2 mohan 2015 tv 1
mohan 2015 tv 1 mohan 2015 radio 5
ram 2015 radio 4 mohan 2016 tv 5
mohan 2015 radio 5 mohan 2016 radio 5
ram 2016 tv 1 ram 2015 tv 2
mohan 2016 tv 5 ram 2015 radio 4
ram 2016 radio 3 ram 2016 tv 1
mohan 2016 radio 5 ram 2016 radio 3
Q7. To sort name wise, in descending order of following df dataframe, so select correct python code for
this:-
df-dataframe df-dataframe
name year item sales name year item sales
ram 2015 tv 2 ram 2015 tv 2
mohan 2015 tv 1 ram 2015 radio 4
ram 2015 radio 4 ram 2016 tv 1
mohan 2015 radio 5 ram 2016 radio 3
ram 2016 tv 1 mohan 2015 tv 1
mohan 2016 tv 5 mohan 2015 radio 5
ram 2016 radio 3 mohan 2016 tv 5
mohan 2016 radio 5 mohan 2016 radio 5
a. print( df.sort_values('name', ascending = True ))
b. print( df.sort_values('name', ascending = False ))
Q8. To sort year wise, in ascending order of following df dataframe, so select correct python code for
this:-
df-dataframe df-dataframe
name year item sales name year item sales
ram 2015 tv 2 ram 2015 tv 2
mohan 2015 tv 1 ram 2015 radio 4
ram 2015 radio 4 mohan 2015 tv 1
mohan 2015 radio 5 mohan 2015 radio 5
ram 2016 tv 1 ram 2016 tv 1
mohan 2016 tv 5 ram 2016 radio 3
ram 2016 radio 3 mohan 2016 tv 5
mohan 2016 radio 5 mohan 2016 radio 5
a. print( df.sort_values('year', ascending = False ))
b. print( df.sort_values('year', ascending = True ))
Q9. To sort year wise, in descending order of following df dataframe, so select correct python code for
this:-
df-dataframe df-dataframe
name year item sales name year item sales
ram 2015 tv 2 ram 2016 tv 1
mohan 2015 tv 1 ram 2016 radio 3
ram 2015 radio 4 mohan 2016 tv 5
mohan 2015 radio 5 mohan 2016 radio 5
ram 2016 tv 1 ram 2015 tv 2
mohan 2016 tv 5 ram 2015 radio 4
ram 2016 radio 3 mohan 2015 tv 1
mohan 2016 radio 5 mohan 2015 radio 5
a. print( df.sort_values('year', ascending = True ))
b. print( df.sort_values('year', ascending = False ))
Q10. To sort item wise, in ascending order of following df dataframe, so select correct python code for
this:-
df-dataframe df-dataframe
name year item sales name year item sales
ram 2015 tv 2 ram 2015 radio 4
mohan 2015 tv 1 ram 2016 radio 3
ram 2015 radio 4 mohan 2015 radio 5
mohan 2015 radio 5 mohan 2016 radio 5
ram 2016 tv 1 ram 2015 tv 2
mohan 2016 tv 5 ram 2016 tv 1
ram 2016 radio 3 mohan 2015 tv 1
mohan 2016 radio 5 mohan 2016 tv 5
a. print( df.sort_values('item', ascending = False ))
b. print( df.sort_values('item', ascending = True ))
Q11. To sort item wise, in descending order of following df dataframe, so select correct python code for
this:-
df-dataframe df-dataframe
name year item sales name year item sales
ram 2015 tv 2 ram 2015 tv 2
mohan 2015 tv 1 ram 2016 tv 1
ram 2015 radio 4 mohan 2015 tv 1
mohan 2015 radio 5 mohan 2016 tv 5
ram 2016 tv 1 ram 2015 radio 4
mohan 2016 tv 5 ram 2016 radio 3
ram 2016 radio 3 mohan 2015 radio 5
mohan 2016 radio 5 mohan 2016 radio 5
a. print( df.sort_values('item', ascending = True ))
b. print( df.sort_values('item', ascending = False ))
Q12. To sort sales wise, in ascending order of following df dataframe, so select correct python code for
this:-
df-dataframe df-dataframe
name year item sales name year item sales
ram 2015 tv 2 ram 2016 tv 1
mohan 2015 tv 1 mohan 2015 tv 1
ram 2015 radio 4 ram 2015 tv 2
mohan 2015 radio 5 ram 2016 radio 3
ram 2016 tv 1 ram 2015 radio 4
mohan 2016 tv 5 mohan 2015 radio 5
ram 2016 radio 3 mohan 2016 tv 5
mohan 2016 radio 5 mohan 2016 radio 5
a. print( df.sort_values('sales', ascending = False ))
b. print( df.sort_values(' sales ', ascending = True ))
Q13. To sort sales wise, in descending order of following df dataframe, so select correct python code for
this:-
df-dataframe df-dataframe
name year item sales name year item sales
ram 2015 tv 2 mohan 2015 radio 5
mohan 2015 tv 1 mohan 2016 tv 5
ram 2015 radio 4 mohan 2016 radio 5
mohan 2015 radio 5 ram 2015 radio 4
ram 2016 tv 1 ram 2016 radio 3
mohan 2016 tv 5 ram 2015 tv 2
ram 2016 radio 3 ram 2016 tv 1
mohan 2016 radio 5 mohan 2015 tv 1
a. print( df.sort_values(‘sales’, ascending = True ))
b. print( df.sort_values('sales', ascending = False ))
first name wise ascending and then year wise ascending for each name
name year item sales
1 mohan 2015 tv 1
3 mohan 2015 radio 5
5 mohan 2016 tv 5
7 mohan 2016 radio 5
0 ram 2015 tv 2
2 ram 2015 radio 4
4 ram 2016 tv 1
6 ram 2016 radio 3
a. print( df.sort_values(['name' , ‘year’], ascending = [False, False] ))
b. print( df.sort_values(['name' , ‘year’], ascending = [True, True] ))
first name wise ascending and then year wise descending for each name
name year item sales
5 mohan 2016 tv 5
7 mohan 2016 radio 5
1 mohan 2015 tv 1
3 mohan 2015 radio 5
4 ram 2016 tv 1
6 ram 2016 radio 3
0 ram 2015 tv 2
2 ram 2015 radio 4
a. print( df.sort_values(['name' , ‘year’], ascending = [False, False] ))
b. print( df.sort_values(['name' , ‘year’], ascending = [True, False] ))
first name wise descending and then year wise descending for each name
name year item sales
4 ram 2016 tv 1
6 ram 2016 radio 3
0 ram 2015 tv 2
2 ram 2015 radio 4
5 mohan 2016 tv 5
7 mohan 2016 radio 5
1 mohan 2015 tv 1
3 mohan 2015 radio 5
a. print( df.sort_values(['name' , ‘year’], ascending = [True, False] ))
b. print( df.sort_values(['name' , ‘year’], ascending = [False, False] ))
first name wise descending and then year wise asending for each name
name year item sales
0 ram 2015 tv 2
2 ram 2015 radio 4
4 ram 2016 tv 1
6 ram 2016 radio 3
1 mohan 2015 tv 1
3 mohan 2015 radio 5
5 mohan 2016 tv 5
7 mohan 2016 radio 5
a. print( df.sort_values(['name' , ‘year’], ascending = [False, True] ))
b. print( df.sort_values(['name' , ‘year’], ascending = [False, False] ))