Q. Given following Series objects:
S1
0 3
1 5
2 6
4 10
5 12
0 3
1 5
2 6
4 10
5 12
S2
0 12
2 10
3 15
4 20
6 27
(a) What will be the result of S1 + S2?
(b) What will be the result of S1 - S2?
Answer :-
(a)
>>> s1+s2
0 15.0
1 NaN
2 16.0
3 NaN
4 30.0
5 NaN
6 NaN
dtype: float64
0 15.0
1 NaN
2 16.0
3 NaN
4 30.0
5 NaN
6 NaN
dtype: float64
(b)
>>> s1-s2
0 -9.0
1 NaN
2 -4.0
3 NaN
4 -10.0
5 NaN
6 NaN
dtype: float64
0 -9.0
1 NaN
2 -4.0
3 NaN
4 -10.0
5 NaN
6 NaN
dtype: float64
The NaN values in Solution are wrong these are real answers they are tested
ReplyDeletea). 0 15
1 15
2 21
3 30
4 39
b). 0 -9
1 -5
2 -9
3 -10
4 -15
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )