PART 2 PANDAS SERIES – SUBJECTIVE QUESTIONS WITH ANSWERS

VERY SHORT ANSWER (1 MARK)  




Q61. What does shape attribute return for a Series?

Ans: It returns a tuple showing number of elements in the Series.


Q62. Which function returns the minimum value in a Series?

Ans: min()


Q63. Write the function used to find standard deviation of a Series.

Ans: std()


Q64. What does sum() function do?

Ans: It returns the sum of all elements of the Series.


Q65. Name the function used to sort Series values.

Ans: sort_values()


Q66. What does idxmax() return?

Ans: It returns the index of maximum value.


Q67. What is the output type of isnull()?

Ans: Boolean Series.


Q68. Write one example of creating an empty Series.

Ans:

pd.Series()

Q69. Can a Series have duplicate index values?

Ans: Yes, duplicate index values are allowed.


Q70. Which function returns unique values of a Series?

Ans: unique()


✍️ SHORT ANSWER (2 MARKS)

Q71. Explain unique() and nunique() functions.

Ans:

  • unique() returns unique values

  • nunique() returns number of unique values


Q72. What is the use of copy() method?

Ans: It creates a duplicate copy of the Series.


Q73. Explain value_counts() with one use.

Ans:
It counts frequency of values, useful in data analysis.


Q74. What is the difference between head(n) and tail(n)?

Ans:

  • head(n) → First n elements

  • tail(n) → Last n elements


Q75. What is reindexing? Why is it used?

Ans:
Reindexing changes index order and is used for data alignment.


Q76. How do you check whether a Series is empty?

Ans: Using empty attribute.


Q77. Explain astype() with example.

Ans:

s = s.astype(float)

Used to change data type.


Q78. What are vectorized operations?

Ans:
Operations applied simultaneously on all elements.


Q79. Write two limitations of Pandas Series.

Ans:

  • One-dimensional only

  • Cannot store tabular data


Q80. Differentiate between dropna() and fillna().

Ans:

  • dropna() removes missing values

  • fillna() replaces missing values


✍️ SHORT ANSWER (3 MARKS)

Q81. Explain creation of Series from NumPy array.

Ans:

import numpy as np import pandas as pd arr = np.array([10, 20, 30]) s = pd.Series(arr)

Q82. Explain sorting by index and by values.

Ans:

  • sort_index() → Sorts by index

  • sort_values() → Sorts by values


Q83. Explain Boolean indexing with suitable example.

Ans:

s = pd.Series([10, 20, 30]) print(s[s > 15])

Q84. Write a program to display count, sum and mean of Series.

Ans:

import pandas as pd s = pd.Series([5, 10, 15]) print(s.count()) print(s.sum()) print(s.mean())

Q85. Explain alignment of data in Series operations.

Ans:
Operations align data based on index labels, not positions.


✍️ LONG ANSWER (5 MARKS)

Q86. Explain different attributes of Pandas Series.

Ans:
Important attributes:

  • index – index labels

  • values – data values

  • dtype – data type

  • size – number of elements

  • shape – structure


Q87. Explain various methods used to analyze data in Series.

Ans:

  • sum() – total

  • mean() – average

  • min() / max() – lowest/highest

  • std() – standard deviation


Q88. Write a program to demonstrate indexing, slicing and Boolean indexing.

Ans:

import pandas as pd s = pd.Series([10, 20, 30, 40], index=['a','b','c','d']) print(s['b']) # Indexing print(s[1:3]) # Slicing print(s[s > 20]) # Boolean indexing

Q89. Explain advantages of Pandas Series in data analysis.

Ans:

  • Labeled indexing

  • Fast computations

  • Missing value handling

  • Built-in functions


Q90. Write a complete program to manage sales data using Pandas Series.

Ans:

import pandas as pd sales = pd.Series([1200, 1500, None, 1800]) print("Total Sales:", sales.sum()) print("Average Sales:", sales.mean()) print("Highest Sales:", sales.max()) print("After removing missing values:") print(sales.dropna())

Post a Comment

Please do note create link post in comment section

Previous Post Next Post