Informatics Practices
Consider the following series object namely S:
0 0.430271
1 0.617328
2 0.265421
3 0.836113
dtype: float64
What will be returned by the following statements?
(a) S * 100
(b) S > 0
(c) S1 = pd.Series(S)
(d) S3 = pd.Series(S1) + 3
Answer
(a) S * 100
Output
0 43.0271
1 61.7328
2 26.5421
3 83.6113
dtype: float64
(b) S > 0
Output
0 True
1 True
2 True
3 True
dtype: bool
(c) S1 = pd.Series(S)
Output
0 0.430271
1 0.617328
2 0.265421
3 0.836113
dtype: float64
(d) S3 = pd.Series(S1) + 3
Output
0 3.430271
1 3.617328
2 3.265421
3 3.836113
dtype: float64
Related Questions
How do you fill all missing values with previous non-missing values?
Consider the following tables Item and Customer and answer the questions that follow:
Table: Item
Item_ID ItemName Manufacturer Price PC01 Personal Computer HCL India 42000 LCO5 Laptop HP USA 55000 PCO3 Personal Computer Dell USA 32000 PC06 Personal Computer Zenith USA 37000 LCO3 Laptop Dell USA 57000 Table: Customer
Item_ID CustomerName City LCO3 N Roy Delhi PCO3 H Singh Mumbai PC06 R Pandey Delhi LCO3 C Sharma Chennai PC01 K Agarwal Bengaluru Assume that the Pandas has been imported as pd.
(a) Create a dataframe called dfI for table Item.
(b) Create a dataframe called dfC for table Customer.
(c) Perform the default join operation on item_ID using two dataframes: dfI and dfC.
(d) Perform the left join operation on item_ID using two dataframes: dfI and dfC.
(e) Perform the right join operation on Item_ID using two dataframes: dfI and dfC.
(f) Perform the default operation on Item_ID using two dataframes: dfI and dfC with the left index as true.
(g) Perform the outer join operation on item_ID using two dataframes: dfI and dfC.
(h) Create a new dataframe dfN using dataframes: dfI and dfC. The new dataframe data will hold both left index and right index true values.
(i) Arrange the dataframe dfN in descending order of Price.
(j) Arrange the dataframe dfN in descending order of City and Price.
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)What will be the output produced by the following codes, considering the Series object S given in Q.13?
(a) print(S[1:4])
(b) print(S[:1])
(c) print(S[0:2])
(d) S[0:2] = 12
print(S)(e) print(S.index)
(f) print(S.values)
The Series object 'S' is as follows:
pencils 20 notebooks 33 scales 52 erasers 10 dtype: int64