Chapter 1 : Python Pandas – I
Sumita Arora Book Exercise Solution of Class 12 Informatics Practices [065]
Type A – Very Short Questions Answers
1. What is the significance of Pandas library?
Ans : => Provide tools to create different data structure
=> Gives several methods to handle and manipulation the large amount of data
=> Also helps in doing analysis of data
=> Fast, Flexible, Easy to use, Vast collection of Tools/Library
2. Name some common data structures of Python’s Pandas library?
Ans : => Series
=> DataFrame
=> Panel
3. How is a Series object different from and similar to ndarrays? Give some examples.
Ans:
Similarity
=> Both supports 1D Data i.e. vector
=> Both allows indexing
=> Both allows vectorized operation
=> Both allows slicing
Differences
=> Index in ndarray is always positive number, while in Series we can give our own indices like number, text, boolean etc.
=> ndarray supports vectorized operation between two same shape numpy array, while Series supports vectorized operation between different shapes of series object
4. Write a single line pandas statement for the following. (Assuming necessary modules have been imported): Declare a Pandas Series named Packets having dataset as:
[125, 92, 104, 92, 85, 116, 87, 90] [CBSE D 2020 C]
Ans: Packets = pd.Series([125, 92, 104, 92, 85, 116, 87, 90])
5. Write commands to print the details of Series Object seal –
a. If the series is empty
b. Indexes of the series
c. The data type of underlying data
d. If the series stores any NaN values.
Ans : (a) seriesobject.empty
(b) seriesobject.index
(c) seriesobject.dtype
(d) seriesobject.hasnans
6. Given the following Series S1 and S2:
S1 | S2 | ||||
A | 10 | A | 80 | ||
B | 40 | B | 20 | ||
C | 34 | C | 74 | ||
D | 60 | D | 90 |
Write the command to find the sum of series S1 and S2. [CBSE Sample Paper 20-21]
Ans: S1 + S2
S1+S2 | |
A | 90 |
B | 60 |
C | 108 |
D | 150 |
Extra Questions:
Question : What will be the result of – (a) S1 + S2 and (b) S1 – S2
[Given in Old Edition Book 2000]
0 | 3 |
1 | 5 |
2 | 6 |
4 | 10 |
5 | 12 |
0 | 12 |
2 | 10 |
3 | 15 |
4 | 20 |
6 | 27 |
S1 S2
Ans: Result of
(a) S1 + S2
0 15.0
1 NaN
2 16.0
3 NaN
4 30.0
5 NaN
6 NaN
(b) S1 – S2
0 -9.0
1 NaN
2 -4.0
3 NaN
4 -10.0
5 NaN
6 NaN