Informatics Practices
Consider following Series object namely S :
0 0.430271
1 0.617328
2 -0.265421
3 -0.836113
dtype:float64
What will be returned by following statements ?
(a) S * 100
(b) S > 0
(c) S1 = pd.Series(S)
(d) S2 = pd.Series(S1) + 3
What will be the values of Series objects S1 and S2 created above ?
Python Pandas
6 Likes
Answer
(a) S * 100
0 43.0271
1 61.7328
2 -26.5421
3 -83.6113
dtype: float64
(b) S > 0
0 True
1 True
2 False
3 False
dtype: bool
(c) S1 = pd.Series(S)
0 0.430271
1 0.617328
2 -0.265421
3 -0.836113
dtype: float64
(d) S2 = pd.Series(S1) + 3
0 3.430271
1 3.617328
2 2.734579
3 2.163887
dtype: float64
The values of Series object S1 created above is as follows:
0 0.430271
1 0.617328
2 -0.265421
3 -0.836113
dtype: float64
The values of Series object S2 created above is as follows:
0 3.430271
1 3.617328
2 2.734579
3 2.163887
dtype: float64
Answered By
1 Like
Related Questions
How would you delete rows from a dataframe ?
Which function would you use to rename the index/column names in a dataframe ?
Consider the same Series object, S, given in the previous question. What output will be produced by following code fragment ?
S.index = ['AMZN', 'AAPL', 'MSFT', 'GOOG'] print(S) print(S['AMZN']) S['AMZN'] = 1.5 print(S['AMZN']) print(S)What will be the output produced by the following code ?
Stationery = ['pencils', 'notebooks', 'scales', 'erasers'] S = pd.Series([20, 33, 52, 10], index = Stationery) S2 = pd.Series([17, 13, 31, 32], index = Stationery) print(S + S2) S = S + S2 print(S + S2)