PANDAS SERIES - WS4 New
PANDAS SERIES - WS4 New
1. Based on the Series S1 given below. What will be an output of the code?
2. Complete the given Python code to make a series and get the required output (ignore the dtype attribute):
Physics 78
Accountancy 50
Biology 34
IP 40
import ____________ pd
data=[78,50,34,40]
subject =["Physics","___________","Humanities","_________"]
S=pd.Series(data, index=_________)
print(__________)
4. The Python code written below has syntactical errors. Rewrite the complete code and underline the
correction(s) made.
import Pandas as pd
stud=[‘Name’:’Ramya’,’Class’:11,’House’:’Red’]
s=p.Series(s)
print(s)
5. Complete the given Python code to get the required output as "California":
import _____________ as pd
data = {'Yosemite': 'California', 'Yellowstone': 'Wyoming', 'Glacier': 'Montana', 'Rocky Mountain': 'Colorado'}
national_parks = pd.Series(_____________)
print(national_parks_____________)
Here lst is a list and ds is a series. What will be the output of the following
commands? Justify your answer.
a) print (lst * 2)
b) print ( ds * 2 )
7. Write a Python program to store the marks of 5 students in a dictionary where the keys are student names
and values are their respective marks. Convert this dictionary into a Pandas Series and identify which students
scored more than 80 marks.
25. Write a program to create a Series to print scalar value “5” four times.
27. Create the following series Student which has the name and marks secured by 5 students.
Arun 96.5
Amal 58.0
Gunal 77.5
Karthick NaN
Kumar 87.5
28. Write the code to create a series s1 with values 10,50,78,35,67,89 and do the following.
a)Change the index to a,b,c,d,e,f,g
b)Name the attribute which gives the no. of elements.
c)Display the second,third and fourth elements
d) Display first five elements
29. Write a program in Python to create series of vowels (Name of the Series as VOWEL).
30. Ananya wants to store her Term-I marks in a Series which is already stored in a NumPy array.
Write the code which will create the series with Subjects as indexes and Marks as elements.