Informatics Practices
Given the following Series S1 and S2 :
| A | 10 |
| B | 40 |
| C | 34 |
| D | 60 |
| A | 80 |
| B | 20 |
| C | 74 |
| D | 90 |
Write the command to find the sum of series S1 and S2.
Python Pandas
6 Likes
Answer
>>> print(S1 + S2)
Output
A 90
B 60
C 108
D 150
dtype: int64
Answered By
2 Likes
Related Questions
Write 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]
Write commands to print following details of a 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
Consider two objects x and y. x is a list whereas y is a Series. Both have values 20, 40, 90, 110.
What will be the output of the following two statements considering that the above objects have been created already ?
(a) print (x*2)
(b) print (y*2)
Justify your answer.
Given a dataframe df as shown below :
A B D 0 15 17 19 1 16 18 20 2 20 21 22 What will be the result of following code statements ?
(a) df['C'] = np.NaN
(b) df['C'] = [2, 5]
(c) df['C'] = [12, 15, 27]