Page 33 - Informatics_Practices_Fliipbook_Class12
P. 33
Solved Exercise
A. Multiple Choice Questions
1. Which of the following statements can be used to retrieve the first element of a Pandas Series?
a. series.head() b. series.first() c. series[0] d. series.loc[0]
2. Which function allows us to access the last five elements of a Pandas Series?
a. series.tail() b. series.last() c. series[-1] d. series.iloc[-1]
3. What is the purpose of the describe() function in Pandas Series?
a. It provides a summary statistics of the Series. b. It returns the first few elements of the Series.
c. It calculates the cumulative sum of the Series. d. It checks for missing values in the Series.
4. How can you add an element to the end of a Pandas Series?
a. series.add() b. series.append() c. series.extend() d. series.insert()
5. Which function should you use to find the minimum value in a Pandas Series?
a. series.min() b. series.minimum()
c. series.min_value() d. series.smallest()
B. State whether the following statements are True or False:
1. The Pandas Series is a one-dimensional array that can store data of various categories. _______
2. A variety of data structures, including lists, arrays, and dictionaries, can be used to generate series. _______
3. Pandas Series can only store numeric information. _______
4. In Pandas Series, the count() method tallies the number of invalid values. _______
5. A Pandas Series index may contain duplicate labels. _______
C. Fill in the blanks.
1. To access the first three elements of a Pandas Series, you can use the syntax __________.
2. The __________ method is used to calculate summary statistics of a Pandas Series.
3. The __________ method computes the sum of all elements in a Pandas Series.
4. The __________ method is used to determine if there are any missing values in a Pandas Series.
5. The __________ operator is used for element-wise addition of two Pandas Series.
D. Answer the following questions:
1. What is the difference between loc and iloc attribute of Pandas Series?
Ans. The loc method is used to access elements in a Pandas Series using label-based indexing, while the iloc method is used
to access elements in a Pandas Series using integer positional indexing.
2. Consider the following two Pandas Series storing financial data of two different companies: Company A and Company B:
Company A's stock prices:
Day1 100.50
Day2 102.75
Day3 105.25
Day4 99.80
Day5 101.20
dtype: float64
Company B's stock prices:
Day1 50.25
Day2 49.80
Day3 52.10
Day4 50.90
Data Handling using Pandas 19

