70+ Important Questions Pandas Series Class 12 IP with Answers

Share with others

Pandas Series Class 12 IP Important Questions

pandas series
pandas series

Q1. What do you mean by Pandas in Python?

Q2. Name three data structures available in Pandas.

Q3. Write command to install pandas in python.

Q4. What do you mean by Series in Python?

Q5. Define data structure in Python.

Q6. Write the code in python to create an empty Series.

Q7. Name a method which is used to create Series in Python.

Q8. Write a program in Python to create a series of first five even numbers.

Q9. Write a program in Python to create series of vowels.

Q10. Write a program in python to create series of given tuple : A = (11, 22, 33, 44, 55)

Q11. Write a program in Python to create the pandas series of all the characters in the name accepted from user.

Q12. Write a program in Python to create a Series in Python from the given dictionary. D = {“Jan” : 31, “Feb” : 28, “Mar” : 31}

Q13. Write a program to create a series from dictionary that stores classes (6,7,8,9,10) as keys and number of students as values.

Q14. Write the output of the following :

import pandas as pd
S1 = pd.Series(12, index = [4, 6, 8])
print(S1)

Q15. Write the output of the following :

import pandas as pd
S1 = pd.Series(range(1,15,3), index=[x for x in "super"])
print(S1)

Pandas Series Class 12 IP Important Questions

Q16. Write the output of the following :

import pandas as pd
S1 = pd.Series(range(100, 150, 10), index=[x for x in "My name is Amit Gandhi".split()])
print(S1)

Q17. Write the output of the following :

import pandas as pd
L1=[1,"A",21]
S1 = pd.Series(data=2*L1)
print(S1)

Q18. Name any two attributes of Series in Python.

Q19. Which property of series return all the index value?

Q20. Write the output of the following :

import numpy as num
import pandas as pd
arr=num.array([1,7,21])
S1 = pd.Series(arr)
print(S1)

Pandas Series Class 12 IP Important Questions

Q21. Write the output of the following :

import numpy as num
import pandas as pd
arr=num.array([1,7,21])
S1 = pd.Series(arr, index = (77,777))
print(S1)

Q22. Write the output of the following :

import numpy as num
import pandas as pd
arr=num.array([31,47,121])
S1 = pd.Series(arr, index = (7,77,777))
print(S1[777])

Q23. Write the output of the following :

import numpy as num
import pandas as pd
arr=num.array([31,47,121])
S1 = pd.Series(arr)
print(S1[0])

Q24. Write the output of the following :

import pandas as pd
L1 = list("My name is Ravi Kumar")
S1 = pd.Series(L1)
print(S1[0])

Q25. Write the output of the following :

import pandas as pd
L1 = list("My name is Ravi Kumar".split( ))
S1 = pd.Series(L1)
print(S1[0])

Pandas Series Class 12 IP Important Questions

Q26. Which property of series returns the number of elements in the series?

Q27. Give an example of creating series from NumPy array.

Q28. Which property of Series help to check whether a Series is empty or not? Explain with example

Q29. Fill in the blanks in the given code :

import pandas as pd
____________ = ____________.Series([1, 2, 3, 4, 5])
print(S1)

Q30. Fill in the blank of given code, if the output is 71.

import pandas as pd
S1 = pd.Series([10, 20, 30, 40, 71,50])
print(S1[ __________ ])

Pandas Series Class 12 IP Important Questions

Q31. Complete the code to get the required output :

import ______ as pd
________ = pd.Series([31, 28, 31], index = ["Jan", "Feb", "Mar"] )
print(S1["_______"])

OUTPUT :

28

Q32. Write the output of the following code :

import pandas as pd
S1 = pd.Series([31, 28, 31, 30, 31], index = ["Jan", "Feb", "Mar", "Apr", "May"])
print("-----------")
print(S1[1:3])
print("-----------")
print(S1[:5])
print("-----------")
print(S1[3:3])
print("-----------")
print(S1["Jan":"May"])

Q33. Write the output of the following code :

import pandas as pd
S1 = pd.Series([31, 28, 31, 30, 31], index = ["Jan", "Feb", "Mar", "Apr", "May"])
print(S1["Jun"])

Q34. Write the output of the following code :

import pandas as pd
S1 = pd.Series([31, 28, 31, 30, 31], index = ["Jan", "Feb", "May", "Apr", "May"])
print(S1["May"])

Q35. Write the output of the following :

import pandas as pd
S1 = pd.Series([31, 28, 31, 30, 31], index = ["Jan", "Feb", "Mar", "Apr", "May"])
print(S1[ [0, 2, 4] ])

Q36. Write the output of the following :

import pandas as pd
S1 = pd.Series([31, 28, 31, 30, 31], index = ["Jan", "Feb", "Mar", "Apr", "May"])
print(S1[0 : 2] * 2)

Q37. Write a program to modify the value 5000 to 7000 in the following Series “S1”

A     25000
B     12000
C     8000
D     5000

Q38. Explain any two properties/attributes of Pandas Series.

Q39. Explain any three methods of Pandas Series.

Q40. Write the output of the following code :

import pandas as pd
S1 = pd.Series([2, 5, 7, 10])
print(S1 + 2)
print(S1 * 2)
print(S1 ** 2)
print(S1 - 2)
print(S1 > 2)

Q41. Write the output of the following code :

import pandas as pd
S1 = pd.Series([2, 5, 7, 10])
S2 = pd.Series([1, 3, 5, 7])
print(S1 + S2)

Q42. Write a program to display only those values greater than 200 in the given Series “S1”

0     300
1     100
2    1200
3    1700

Q43. Write a program to display the following Series “S1” in descending order.

0     300
1 100
2 1200
3 1700

Q44. Write the output of the following :

import pandas as pd
S1 = pd.Series([3, 1, 12, 17], index = ("a","b","c","d"))
S2 = pd.Series([4, 5, 6, 7], index = ("a","b","e","f"))
print(S1*S2)

Q45. Write the output of the following :

import pandas as pd
S1 = pd.Series([3, 1, 12, 17], index = ("a", "b", "c", "d"))
S2 = pd.Series([4, 5, 6, 7], index = ("a", "b", "e", "f"))
print(S1.mul(S2, fill_value = 0))

Q46. Name the methods used for multiplication and division of two Series in Python.

Q47. Differentiate between Pandas Series and NumPy Arrays.

Q48. A Series object can have duplicate index.(T/F)

Q49. A Series object always have indexes 0 to n-1. (T/F)

Q50. ________________ is a Pandas data structure that represent one dimensional array containing a sequence of values of any data type

Q51. Write a program to change the index of the following Series “S1” from (0, 1, 2, 3) to (a, b, c,d).

0    120
1     75
2     85
3     95

Q52. Write the output of the following :

import pandas as pd
L1=[1, 2, 3, 4]
S1 = pd.Series(L1 * 2) 
S2 = pd.Series(S1 * 2)
print(S1)
print(S2)

Q53. Consider the following Series object “S1” and write the output of the following statement :

0    21
1    41
2    62
3    81
4    23
5    45
6    68
7    89


 import pandas as pd
 L1=[21, 41, 62, 81, 23, 45, 68, 89]
 S1 = pd.Series(L1)
 print("1. ",S1.index)

 print("2. ",S1.values)

 print("3. ",S1.shape)

 print("4. ",S1.ndim)

 print("5. ",S1.size)

 print("6. ",S1.nbytes)

 print("7. ",S1[0])

 print("8. ",S1[2]+S1[0])

 print("9. ",S1[5]**2)

 print("10. ",S1.empty)

 print("11.\n",S1[[1, 5, 6]])

 print("12.\n",S1[5 : 7],"\n")

 print("13.\n",S1[: : -1])

 print("14.\n",S1>60)

 print("15.\n",S1[S1>60])

 print("16.\n",len(S1))

 print("17.\n",S1.count())

 print("18.\n",S1.head())

 print("19.\n",S1.tail())

 print("20.\n",S1[4:5] + S1[4:5])

Q54. Consider the following Series object “S1” and “S2” and write the output of the following code :

S1 S2
0 2
1 4
2 6
3 8
4 10
0 1
1 2
2 3
3 4
4 5
Pandas Series
import pandas as pd
S1=pd.Series([2, 4, 6, 8, 10])
S2=pd.Series([1, 2, 3, 4, 5])
print(S1+S2)
print(S1-S2)
print(S1*S2) 
print(S1/S2) 
print(S1.mul(2)) 
print(S1*3)
print(S1+3)
print(S1-3)
print(S1.div(S2))

                        

Q55. Write a program to perform basic mathematical operation on two series.

Q56. Write a program to create series from the given dictionary. D={ “A” : “Apple”, “B” : “Boy”, “C” : “Cat”}

Q57. Write a program to create Pandas Series from the given NumPy array. A=[1,2,3,4,5,6,7]

Q58. Write a program to display only first n rows from the given Pandas Series ‘S1’. Accept n from the user.

0    1
1 2
2 3
3 4
4 5
5 6
6 7

Q59. Write a program to display values greater than 250 from the given Pandas Series “S1”

0    150
1    252
2    35
3    420
4    50
5    61
6    275

Q60. Write a program to count the number of values less than 200 from the given Pandas Series.

0    150
1 252
2 35
3 420
4 50
5 61
6 275

Q61. Write a program to increase those value in the given Pandas Series by 50 which are less than 70.

0    150
1 252
2 35
3 420
4 50
5 61
6 275

Q62. Write a program to create a Series whose values are characters of the name accepted from the user. for example :

Enter Your Name  : Suman
Series is :
0     S
1     u
2     m
3     a
4     n

Q63. Write a program to arrange the given Pandas Series in increasing order.

0    150
1 252
2 85
3 420
4 111
5 275

Q64. Write a program to add a new value (Accept that value from the user) in the given Pandas Series.

0    150
1 252
2 85
3 420
4 111
5 275

Q65. Write a program to display the sum and average of all the values in the given Pandas Series.

0    15
1     2
2    8
3    4
4    1
5    5
6    14

Q66. Write a program to find the minimum, maximum value of given Pandas Series.

0    15
1 2
2 8
3 4
4 1
5 5
6 14

Q67. Write a program to display multiple of 5 from the given Pandas Series.

0    15
1     2
2    8
3    4
4    1
5    25
6    30

Q68. Write a program in python to display all values of given pandas series with first character in upper case. for example

Original Series is  :

0     ravi
1     ram
2     sonu
3     david

Expected Output :

0     Ravi
1      Ram
2     Sonu
3    David
dtype: object

Q69. Write a program to display all odd numbers and its sum from the given Pandas Series.

0    15
1 2
2 8
3 4
4 1
5 25
6 30

Q70. Write the output of the following :

import pandas as pd
L=[1, 2]
for i in range(25, 95, 10):
L.append(i)
S1 = pd.Series(L)
print(S1)

Q71. Write the output of the following :

import pandas as pd
D = { }
for i in range(25, 95, 10):
D[i]=i+10
S1 = pd.Series(D)
print(S1)

Q72. Write the output of the following :

import pandas as pd
S1 = pd.Series(range(1, 20, 3))
print(S1)

Pandas Series Class 12 IP Important Questions

Disclaimer : I tried to give you the correct “Pandas Series Class 12 IP Important Questions” , but if you feel that there is/are mistakes in any question or answers of “Pandas Series Class 12 IP Important Questions” given above, you can directly contact me at csiplearninghub@gmail.com. Book and Study material available on CBSE official website is used as reference to create above “Pandas Series Class 12 IP Important Questions

Important Points to Remember about Pandas Series

NumPy, Pandas and Matplotlib are Python libraries for scientific and analytical use. 

pip install pandas is the command to install Pandas library.

A data structure is a collection of data values and the operations that can be applied to that data. It enables efficient storage, retrieval and  modification to the data. 

Two main data structures in Pandas library are Series and DataFrame. To use these data structures, we first need to import the Pandas library.

A Series is a one-dimensional array containing a sequence of values. Each value has a data label associated with it also called its index. 

The two common ways of accessing the elements of a series are Indexing and Slicing.

There are two types of indexes: positional index and labelled index. Positional index takes an integer value that corresponds to its position in the series starting from 0, whereas labelled index takes any user-defined label as index 

When positional indices are used for slicing, the value at end index position is excluded, i.e., only (end - start) number of data values of the series are extracted. However with labelled indexes the value at the end index label is also included in the output. 

All basic mathematical operations can be performed on Series either by using the operator or by using appropriate methods of the Series object. 

While performing mathematical operations index matching is implemented and if no matching indexes are found during alignment, Pandas returns NaN so that the operation does not fail.

Class 12 Computer Science Sample Paper 2020-2021.

Class 12 Computer Science Sample Paper Marking Scheme

Class 12 Computer Science Chapter wise MCQ


Share with others

Leave a Reply

%d bloggers like this: