Q. Using the Series created in Question 5, write commands for the following:

a) Set all the values of Vowels to 10 and display the Series.

b) Divide all values of Vowels by 2 and display the Series.

c) Create another series Vowels1 having 5 elements with index labels ‘a’, ‘e’, ‘i’, ‘o’ and ‘u’ having values [2,5,6,3,8] respectively.

d) Add Vowels and Vowels1 and assign the result to Vowels3.

e) Subtract, Multiply and Divide Vowels by Vowels1.

f) Alter the labels of Vowels1 to [‘A’, ‘E’, ‘I’, ‘O’, ‘U’].


Answer :-

a =

import pandas as pd
vowels = pd.Series([1,2,3,4,5],index=list('aeiou'))
print(vowels)
print()
vowels[vowels!='not ten']=10 # all values changed to '10'
print(vowels)



b =

import pandas as pd
vowels = pd.Series([1,2,3,4,5],index=list('aeiou'))
print(vowels)
print()
vowels[vowels!='not ten']=10 # all values changed to '10'
print(vowels)
vowels=vowels/2
print(vowels)


c =

import pandas as pd
vowels1 = pd.Series([2,5,6,3,8],index=list('aeiou'))
print(vowels)


d =

import pandas as pd
vowels = pd.Series([1,2,3,4,5],index=list('aeiou'))
print()
vowels[vowels!='not ten']=10 # all values changed to '10'
vowels=vowels/2
vowels1 = pd.Series([2,5,6,3,8],index=list('aeiou'))
vowels3=vowels1+vowels
print(vowels3)


e =

import pandas as pd
vowels = pd.Series([1,2,3,4,5],index=list('aeiou'))
print()
vowels[vowels!='not ten']=10 # all values changed to '10'
vowels=vowels/2
vowels1 = pd.Series([2,5,6,3,8],index=list('aeiou'))
vowels3=vowels1+vowels
print(vowels3)
Subtract=vowels-vowels1
Multiply=vowels*vowels1
Divide=vowels/vowels1


f =

vowels1.index= ['A', 'E', 'I', 'O', 'U']
print(vowels1)

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post