70+ CBSE 12th Data Handling Using Pandas – Series Important Questions

70+ CBSE 12th Data Handling Using Pandas – Series Important Questions

Boost your Pandas skills with our comprehensive question bank! Over 70 CBSE 12th Informatics Practices questions to help you master Pandas. Practice now and ace your exams! #Pandas #CBSE #InformaticsPractices #Python #DataScience.Pandas for CBSE 12th Informatics Practices with these 70+ curated questions! Covering the latest syllabus, these exercises will strengthen your understanding of data manipulation, analysis, and visualization. Perfect your skills and ace your exams by practicing these problems. Start now and become a Pandas pro effortlessly

1.What is Pandas Libraries?

It is a collection of built in modules that allow us to perform many actions without writing detailed programs for it. Each library in Python contains a large number of modules that one can import and use.

2.What are the three well-established Python libraries used for scientific and analytical purposes?

Answer: The three well-established Python libraries used for scientific and analytical purposes are NumPy, Pandas, and Matplotlib.

4.Explain the significance of the Pandas library in data manipulation and analysis

  • The Pandas library is significant in data manipulation and analysis because it provides an easy-to-use set of tools for importing, exporting, and processing data.
  • It is built on top of libraries like NumPy and Matplotlib and offers rich functions for handling data efficiently.
  • Pandas makes the process of analyzing data more organized and effective.

4.List and describe the three important data structures in Pandas.

  1. .Answer: The three important data structures in Pandas are:
    • Series: A one-dimensional array-like object that can hold any data type.
    • DataFrame: A two-dimensional, tabular data structure with labeled axes (rows and columns), which is most commonly used in data analysis.
    • Panel: A three-dimensional data structure, but it is less commonly used than Series and DataFrame. It is used to store data across multiple DataFrames.

5.How does Matplotlib enhance data visualization in Python?

  • Matplotlib enhances data visualization in Python by allowing users to create publication-quality plots with just a few lines of code. eg. plotting bar chart,histogram,line chart etc
  • It can generate a variety of plots, such as histograms, bar charts, scatterplots, and more, which help in visualizing data efficiently.
  • It works well with other libraries like NumPy and Pandas for seamless data visualization.

6.What are the advantages of using Python libraries like NumPy, Pandas, and Matplotlib for data analysis and visualization?

  • The advantages of using Python libraries like NumPy, Pandas, and Matplotlib include their ability to simplify complex tasks like data manipulation, transformation, and visualization.
  • These libraries are designed to handle large datasets efficiently, allowing quick access to data.
  • They also provide easy-to-use functions that save time and effort compared to writing detailed programs from scratch.

    7.How to Install Pandas in python?

    Pandas can be installed by using pip install pandas in command prompt.

    8.What is a Pandas Series?

    Answer: A Pandas Series is a one-dimensional labeled array capable of holding any data type (integers, strings, floats, etc.). It is similar to a column in a table or a one-dimensional array in NumPy.

    9.Write a Python code to create a Pandas Series ser with values 1, 2, 3, 4, 5.

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

    10.Write a Python code to create a Pandas Series ser with values 10, 20, 30, 40, 50 and indices a, b, c, d, e.

    import pandas as pd
    ser = pd.Series([10, 20, 30, 40, 50], index=['a', 'b', 'c', 'd', 'e'])
    print(ser)

    11.Write a Python code to access the element at index ‘c’ in the Pandas Series ser.

    import pandas as pd
    ser = pd.Series([10, 20, 30, 40, 50], index=['a', 'b', 'c', 'd', 'e'])
    print(ser['c'])

    12. Write a Python code to access the third element of the Pandas Series ser (using integer location).

    Answer:

    import pandas as pd
    ser = pd.Series([10, 20, 30, 40, 50])
    print(ser[2])

    13. Write a Python code to create a Pandas Series ser from a dictionary {'a': 1, 'b': 2, 'c': 3}.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series({'a': 1, 'b': 2, 'c': 3})
    print(ser)
    

    14. Write a Python code to create a Pandas Series ser from a NumPy array [1, 2, 3, 4].

    Answer:

    pythonCopyimport pandas as pd
    import numpy as np
    ser = pd.Series(np.array([1, 2, 3, 4]))
    print(ser)
    

    15. Write a Python code to check the data type of the elements in the Pandas Series ser.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([10, 20, 30, 40, 50])
    print(ser.dtypes)
    

    16. Write a Python code to find the index labels of the Pandas Series ser.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([1, 2, 3], index=['a', 'b', 'c'])
    print(ser.index)
    

    17. Write a Python code to check the values of the Pandas Series ser.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([10, 20, 30])
    print(ser.values)
    

    18. Write a Python code to perform element-wise addition by adding 2 to every element in the Pandas Series ser.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([10, 20, 30])
    print(ser + 2)
    

    19. Write a Python code to find the sum of all elements in the Pandas Series ser.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([10, 20, 30])
    print(ser.sum())
    

    20. Write a Python code to calculate the mean of the elements in the Pandas Series ser.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([10, 20, 30])
    print(ser.mean())
    

    21. Write a Python code to sort the Pandas Series ser in ascending order.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([5, 2, 8, 1])
    print(ser.sort_values())
    

    22. Write a Python code to sort the Pandas Series ser in descending order.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([5, 2, 8, 1])
    print(ser.sort_values(ascending=False))
    

    23. Write a Python code to find the index of the maximum value in the Pandas Series ser.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([1, 4, 3, 2])
    print(ser.idxmax())
    

    24. Write a Python code to replace missing (NaN) values in the Pandas Series ser with 0.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([1, 2, None, 4])
    print(ser.fillna(0))
    

    25. Write a Python code to check for missing values in the Pandas Series ser.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([1, 2, None, 4])
    print(ser.isnull())
    

    26. Write a Python code to filter values greater than 10 in the Pandas Series ser.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([5, 15, 8, 20, 10])
    print(ser[ser > 10])
    

    27. Write a Python code to check if a value 3 exists in the Pandas Series ser.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([1, 2, 3, 4, 5])
    print(3 in ser.values)
    


    28. Write a Python code to convert the Pandas Series ser to a NumPy array.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([1, 2, 3, 4])
    print(ser.to_numpy())
    

    29. Write a Python code to get the index of the first occurrence of value 2 in the Pandas Series ser.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([1, 2, 3, 2, 4])
    print(ser[ser == 2].index[0])
    


    30. Write a Python code to check if a Pandas Series ser is empty.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([])
    print(ser.empty)
    

    31. Write a Python code to find the maximum value of the Pandas Series ser.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([10, 20, 30, 40])
    print(ser.max())
    


    32. Write a Python code to calculate the difference between each element and its predecessor in the Pandas Series ser.

    Answer:

    import pandas as pd
    ser = pd.Series([10, 20, 30, 40])
    print(ser.diff())

    33.Sejal, a Python programmer, has been given the task to create a Pandas Series ser to store the following data:

    1, 2, 3, 4, 5

    Write the Python code to create this Series.

    Answer:

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

    34. Sejal needs to create a Pandas Series ser from a dictionary containing:

    {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}

    Write the Python code to create this Series.

    Answer:

    import pandas as pd
    ser = pd.Series({'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5})
    print(ser)

    35. Sejal is given a task to create two Series. One should store product names and the other should store product prices, with appropriate row labels.

    Write the Python code to create the following Series:

    Product_name:
    B1001, V3002, M4002, M4007, C6005
    Product_price:
    130, 100, 150, 190, 200

    Answer:

    import pandas as pd
    product_names = pd.Series(['Butterscotch', 'Vanilla', 'Mango Zap', 'Magnum', 'Cassatta'], index=['B1001', 'V3002', 'M4002', 'M4007', 'C6005'])
    product_prices = pd.Series([130, 100, 150, 190, 200], index=['B1001', 'V3002', 'M4002', 'M4007', 'C6005'])
    print(product_names)
    print(product_prices)

    36. Sejal is asked to combine the two Series from the previous question into a dictionary.

    Write the Python code to create a dictionary where the keys are 'Product_name' and 'Product_price' and the values are the corresponding Series.

    Answer:

    import pandas as pd
    product_names = pd.Series(['Butterscotch', 'Vanilla', 'Mango Zap', 'Magnum', 'Cassatta'], index=['B1001', 'V3002', 'M4002', 'M4007', 'C6005'])
    product_prices = pd.Series([130, 100, 150, 190, 200], index=['B1001', 'V3002', 'M4002', 'M4007', 'C6005'])
    products_dict = {'Product_name': product_names, 'Product_price': product_prices}
    print(products_dict)

    37. Sejal is tasked with creating a Pandas Series ser from the following NumPy array:

    [10, 20, 30, 40]

    Write the Python code to create this Series.

    Answer:

    import pandas as pd
    import numpy as np
    ser = pd.Series(np.array([10, 20, 30, 40]))
    print(ser)

    38. Sejal needs to create a Pandas Series ser filled with 5 repeated 5 times.

    Write the Python code to create this Series.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series(5, index=[0, 1, 2, 3, 4])
    print(ser)
    

    39. Sejal needs to find the sum of all the elements in the following Series:

    ser = pd.Series([1, 2, 3, 4, 5])

    Write the Python code to calculate the sum.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([1, 2, 3, 4, 5])
    print(ser.sum())
    

    40. Sejal needs to find the maximum value in the following Series:

    ser = pd.Series([15, 23, 12, 30, 45])

    Write the Python code to find the maximum value.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([15, 23, 12, 30, 45])
    print(ser.max())
    


    41. Sejal is tasked with finding the mean of the Series ser = pd.Series([5, 10, 15, 20]).

    Write the Python code to calculate the mean.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([5, 10, 15, 20])
    print(ser.mean())
    


    42. Sriti wants to access the element at index M4002 in the following Series:

    ser = pd.Series([130, 100, 150, 190, 200], index=['B1001', 'V3002', 'M4002', 'M4007', 'C6005'])

    Write the Python code to access the element at index M4002.

    Answer:

    import pandas as pd
    ser = pd.Series([130, 100, 150, 190, 200], index=['B1001', 'V3002', 'M4002', 'M4007', 'C6005'])
    print(ser['M4002'])

    43. Sisti wants to filter out all elements greater than 15 from the following Series:

    ser = pd.Series([10, 20, 30, 40])

    Write the Python code to filter the elements.

    Answer:

    import pandas as pd
    ser = pd.Series([10, 20, 30, 40])
    print(ser[ser > 15])

    44. Sejal wants to replace missing values (NaN) with 0 in the following Series:

    ser = pd.Series([1, 2, None, 4])

    Write the Python code to replace NaN values with 0.

    Answer:

    import pandas as pd
    ser = pd.Series([1, 2, None, 4])
    print(ser.fillna(0))


    45. Sanjay needs to slice the first 3 elements from the Series ser = pd.Series([10, 20, 30, 40]).

    Write the Python code to slice the first 3 elements.

    Answer:

    import pandas as pd
    ser = pd.Series([10, 20, 30, 40])
    print(ser[:3])

    46. Harshi is tasked with checking if the Series ser = pd.Series([]) is empty.

    Write the Python code to check if the Series is empty.

    Answer:

    pythonCopyimport pandas as pd
    ser = pd.Series([])
    print(ser.empty)
    

    47. Simran is asked to create a Series ser with random integers between 1 and 100, with 5 elements.Write the Python code to generate the Series.

    Answer:

    import pandas as pd
    import numpy as np
    ser = pd.Series(np.random.randint(1, 101, size=5))
    print(ser)


    48. Amir wants to find the unique values in the Series ser = pd.Series([1, 2, 2, 3, 4, 4]).Write the Python code to find unique values.

    Answer:

    import pandas as pd
    ser = pd.Series([1, 2, 2, 3, 4, 4])
    print(ser.unique())

    49. Sejal needs to check if there are any missing values in the Series ser = pd.Series([1, 2, None, 4]).Write the Python code to check for missing values.

    Answer:

    import pandas as pd
    ser = pd.Series([1, 2, None, 4])
    print(ser.isnull())

    50. Amir is tasked with calculating the standard deviation of the Series ser = pd.Series([1, 2, 3, 4, 5]).Write the Python code to calculate the standard deviation.

    Answer:

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

    51. Saj needs to multiply each element in the Series ser = pd.Series([1, 2, 3]) by 2.

    Write the Python code to perform the operation.

    Answer:

    import pandas as pd
    ser = pd.Series([1, 2, 3])
    print(ser * 2)

    52. Akshay is tasked with finding the median of the Series ser = pd.Series([1, 5, 7, 9]).

    Write the Python code to find the median.

    Answer:

    import pandas as pd
    ser = pd.Series([1, 5, 7, 9])
    print(ser.median())

    Find the Python Output based Questions.

    53. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([5, 10, 15, 20])
    print(ser)
    

    Answer:

    0     5
    1    10
    2    15
    3    20
    dtype: int64
    

    54. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([1, 2, 3, 4], index=['A', 'B', 'C', 'D'])
    print(ser['B'])
    

    Answer:

    2
    

    55. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([10, 20, 30, 40])
    print(ser[1:3])
    

    Answer:

    1    20
    2    30
    dtype: int64
    

    56. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([100, 200, 300], index=['A', 'B', 'C'])
    print(ser + 10)
    

    Answer:

    A    110
    B    210
    C    310
    dtype: int64
    

    57. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([2, 4, 6, 8])
    print(ser * 2)
    

    Answer:

    0     4
    1     8
    2    12
    3    16
    dtype: int64
    

    58. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([10, 20, 30], index=['X', 'Y', 'Z'])
    print(ser['Y'])
    

    Answer:

    20
    

    59. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([2, 4, 6, 8])
    print(ser.head(2))
    

    Answer:

    0    2
    1    4
    dtype: int64
    

    60. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([1, 2, 3, 4], index=['a', 'b', 'c', 'd'])
    print(ser.tail(2))
    

    Answer:

    c    3
    d    4
    dtype: int64
    

    61. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([1, 2, 3], index=['Apple', 'Banana', 'Cherry'])
    print(ser['Banana'])
    

    Answer:

    2
    

    62. Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([5, 10, 15], index=['A', 'B', 'C'])
    print(ser + pd.Series([1, 2, 3], index=['A', 'B', 'C']))
    

    Answer:

    A     6
    B    12
    C    18
    dtype: int64
    

    63. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([5, 10, 15, 20], index=['A', 'B', 'C', 'D'])
    print(ser * 3)
    

    Answer:

    A     15
    B     30
    C     45
    D     60
    dtype: int64
    

    64. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([100, 200, 300], index=['X', 'Y', 'Z'])
    print(ser['X'] + ser['Y'])
    

    Answer:

    300
    

    65. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([1, 3, 5], index=['A', 'B', 'C'])
    print(ser['B'] - 1)
    

    Answer:

    2
    

    66. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([5, 10, 15], index=['X', 'Y', 'Z'])
    ser = ser * 2
    print(ser)
    

    Answer:

    X    10
    Y    20
    Z    30
    dtype: int64
    

    67. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([20, 30, 40], index=['A', 'B', 'C'])
    print(ser[1:])
    

    Answer:

    B    30
    C    40
    dtype: int64
    

    68. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([100, 200, 300], index=['A', 'B', 'C'])
    print(ser + 50)
    

    Answer:

    A    150
    B    250
    C    350
    dtype: int64
    

    69. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser1 = pd.Series([1, 2, 3], index=['A', 'B', 'C'])
    ser2 = pd.Series([4, 5, 6], index=['A', 'B', 'C'])
    print(ser1 + ser2)
    

    Answer:

    A     5
    B     7
    C     9
    dtype: int64
    

    70. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([10, 20, 30], index=['X', 'Y', 'Z'])
    print(ser[ser > 10])
    

    Answer:

    Y    20
    Z    30
    dtype: int64
    

    71. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([3, 6, 9], index=['A', 'B', 'C'])
    print(ser * 2)
    

    Answer:

    A     6
    B    12
    C    18
    dtype: int64
    

    72. Question:

    Find the output of the following Python code:

    import pandas as pd
    ser = pd.Series([10, 20, 30], index=['A', 'B', 'C'])
    print(ser.head(2))
    

    Answer:

    A    10
    B    20
    dtype: int64
    
    Review Your Cart
    0
    Add Coupon Code
    Subtotal

     
    Scroll to Top